Table of Contents

Method OnTestStarting

Namespace
Xunit.v3
Assembly
xunit.v3.core.dll

OnTestStarting(TContext)

This method is called just before the test is run. By default, this sends TestStarting. Override this to enable any extensibility related to test start.

protected virtual ValueTask<bool> OnTestStarting(TContext ctxt)

Parameters

ctxt TContext

The context that describes the current test

Returns

ValueTask<bool>

Return true if test execution should continue; false if it should be shut down.

Remarks

This method runs during Initializing and any exceptions thrown will contribute to test failure (and will prevent the test from running). Even if this method records exceptions, OnTestFinished(TContext, decimal, string, string[]?, IReadOnlyDictionary<string, TestAttachment>?) will be called.

OnTestStarting(TContext, bool, int)

This is a helper that allows passing explicit and timeout values, since those are not part of the core object model.

protected ValueTask<bool> OnTestStarting(TContext ctxt, bool @explicit, int timeout)

Parameters

ctxt TContext

The context that describes the current test

explicit bool

A flag which indicates whether this is an explicit test

timeout int

The timeout for running this test

Returns

ValueTask<bool>