Table of Contents

Class TestCaseRunnerBase<TContext, TTestCase>

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

A base class that provides default behavior when running test cases.

public abstract class TestCaseRunnerBase<TContext, TTestCase> where TContext : TestCaseRunnerBaseContext<TTestCase> where TTestCase : class, ITestCase

Type Parameters

TContext

The context type used by the runner

TTestCase

The type of the test case used by the test framework. Must derive from ITestCase.

Inheritance
TestCaseRunnerBase<TContext, TTestCase>
Derived
Inherited Members

Remarks

This class does not make any test-related assumptions about test cases, only that at some point, a test case will be "run" and results will be provided. As such, it has no definitions that related to tests (or ITest). The intention with this base class is that it can serve as a base for non-traditional test cases, such as injecting errors into the test pipeline during discovery that aren't uncovered until execution time.

Constructors

TestCaseRunnerBase()

Initializes a new instance of the TestCaseRunnerBase<TContext, TTestCase> class.

Methods

OnError(TContext, Exception)

This method is called when an exception was thrown by OnTestCaseFinished(TContext, RunSummary). By default, this sends ErrorMessage.

OnTestCaseCleanupFailure(TContext, Exception)

This method is called when an exception was thrown while cleaning up, after the test case has run. By default, this sends TestCaseCleanupFailure.

OnTestCaseFinished(TContext, RunSummary)

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

OnTestCaseStarting(TContext)

This method will be called before the test case has started running. TBy default, this sends TestCaseStarting. Override this to enable any extensibility related to test case start.

Run(TContext)

Executes the administrivia around running a test case, while leaving the actual test case execution up to RunTestCase(TContext, Exception?).

RunTestCase(TContext, Exception?)

Override this to run the test case.

SetTestContext(TContext, TestEngineStatus)

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