Table of Contents

Class XunitTestClassRunnerBase<TContext, TTestClass, TTestMethod, TTestCase>

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

The test class runner for xUnit.net v3 tests (with overridable context).

public abstract class XunitTestClassRunnerBase<TContext, TTestClass, TTestMethod, TTestCase> : TestClassRunner<TContext, TTestClass, TTestMethod, TTestCase> where TContext : XunitTestClassRunnerBaseContext<TTestClass, TTestCase> where TTestClass : class, IXunitTestClass where TTestMethod : class, IXunitTestMethod where TTestCase : class, IXunitTestCase

Type Parameters

TContext
TTestClass
TTestMethod
TTestCase
Inheritance
TestClassRunner<TContext, TTestClass, TTestMethod, TTestCase>
XunitTestClassRunnerBase<TContext, TTestClass, TTestMethod, TTestCase>
Derived
Inherited Members

Methods

CreateTestClassConstructorArguments(TContext)

Creates the arguments for the test class constructor. By default just returns an empty set of arguments. Override to find the arguments for the constructor.

protected override ValueTask<object?[]> CreateTestClassConstructorArguments(TContext ctxt)

Parameters

ctxt TContext

The context that describes the current test class

Returns

ValueTask<object[]>

The test class constructor arguments.

Remarks

This method runs during Initializing and any exceptions thrown will contribute to test class failure (and will prevent the test class from running)

FormatConstructorArgsMissingMessage(TContext, ConstructorInfo, IReadOnlyList<Tuple<int, ParameterInfo>>)

Gets the message to be used when the constructor is missing arguments.

protected virtual string FormatConstructorArgsMissingMessage(TContext ctxt, ConstructorInfo constructor, IReadOnlyList<Tuple<int, ParameterInfo>> unusedArguments)

Parameters

ctxt TContext

The context that describes the current test class

constructor ConstructorInfo

The constructor that was selected

unusedArguments IReadOnlyList<Tuple<int, ParameterInfo>>

The arguments that had no matching parameter values

Returns

string

GetConstructorArgument(TContext, ConstructorInfo, int, ParameterInfo)

Tries to supply a test class constructor argument.

protected virtual ValueTask<object?> GetConstructorArgument(TContext ctxt, ConstructorInfo constructor, int index, ParameterInfo parameter)

Parameters

ctxt TContext

The context that describes the current test class

constructor ConstructorInfo

The constructor that will be used to create the test class.

index int

The parameter index.

parameter ParameterInfo

The parameter information.

Returns

ValueTask<object>

Returns the constructor argument if available, null otherwise.

OnTestClassFinished(TContext, RunSummary)

This method will be called when the test class has finished running. By default, this sends TestClassFinished. Override this to enable any extensibility related to test class finish.

protected override ValueTask<bool> OnTestClassFinished(TContext ctxt, RunSummary summary)

Parameters

ctxt TContext

The context that describes the current test class

summary RunSummary

The execution summary for the test class

Returns

ValueTask<bool>

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

Remarks

This method runs during CleaningUp and any exceptions thrown will contribute to test class cleanup failure.

OnTestClassStarting(TContext)

This method will be called before the test class has started running. By default, this sends TestClassStarting. Override this to enable any extensibility related to test class start.

protected override ValueTask<bool> OnTestClassStarting(TContext ctxt)

Parameters

ctxt TContext

The context that describes the current test class

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 class failure (and will prevent the test class from running). Even if this method records exceptions, OnTestClassFinished(TContext, RunSummary) will be called.

OrderTestCases(TContext)

Orders the test cases in the class. By default does not re-order the test cases. Override this to provide custom test case ordering.

protected override IReadOnlyCollection<TTestCase> OrderTestCases(TContext ctxt)

Parameters

ctxt TContext

The context that describes the current test class

Returns

IReadOnlyCollection<TTestCase>

Remarks

This method runs during Running and any exceptions thrown will contribute to test class failure

SelectTestClassConstructor(TContext)

Selects the test constructor.

protected virtual ConstructorInfo? SelectTestClassConstructor(TContext ctxt)

Parameters

ctxt TContext

The context that describes the current test class

Returns

ConstructorInfo

SetTestContext(TContext, TestEngineStatus)

Sets the current TestContext for the current test class and the given test class status.

protected override void SetTestContext(TContext ctxt, TestEngineStatus testClassStatus)

Parameters

ctxt TContext

The context that describes the current test class

testClassStatus TestEngineStatus

The current test class status.

Remarks

This method must never throw. Behavior is undefined if it does. Instead, exceptions that occur should be recorded in the aggregator in ctxt and will be reflected in a way that's appropriate based on when this method is called.