Class TestRunner<TContext, TTest>
- Namespace
- Xunit.v3
- Assembly
- xunit.v3.core.dll
A base class that provides default behavior when running a test. This includes support for skipping tests.
public abstract class TestRunner<TContext, TTest> : TestRunnerBase<TContext, TTest> where TContext : TestRunnerContext<TTest> where TTest : class, ITest
Type Parameters
TContextThe context type used by the runner
TTestThe test type used by the test framework. Must derive from ITest.
- Inheritance
-
TestRunnerBase<TContext, TTest>TestRunner<TContext, TTest>
- Derived
- Inherited Members
-
TestRunnerBase<TContext, TTest>.GetAttachments(TContext)TestRunnerBase<TContext, TTest>.GetTestOutput(TContext)TestRunnerBase<TContext, TTest>.GetWarnings(TContext)TestRunnerBase<TContext, TTest>.OnError(TContext, Exception)TestRunnerBase<TContext, TTest>.OnTestCleanupFailure(TContext, Exception)TestRunnerBase<TContext, TTest>.OnTestFailed(TContext, Exception, decimal, string, string[])TestRunnerBase<TContext, TTest>.OnTestFinished(TContext, decimal, string, string[], IReadOnlyDictionary<string, TestAttachment>)TestRunnerBase<TContext, TTest>.OnTestNotRun(TContext, string, string[])TestRunnerBase<TContext, TTest>.OnTestPassed(TContext, decimal, string, string[])TestRunnerBase<TContext, TTest>.OnTestSkipped(TContext, string, decimal, string, string[])TestRunnerBase<TContext, TTest>.OnTestStarting(TContext)TestRunnerBase<TContext, TTest>.OnTestStarting(TContext, bool, int)TestRunnerBase<TContext, TTest>.Run(TContext)TestRunnerBase<TContext, TTest>.RunTest(TContext)TestRunnerBase<TContext, TTest>.SetTestContext(TContext, TestEngineStatus, TestResultState, object)TestRunnerBase<TContext, TTest>.ShouldTestRun(TContext)TestRunnerBase<TContext, TTest>.UpdateTestContext(object, TestResultState)
Remarks
This class does not make any assumptions about what it means to run an individual test, just that at some point, the test will be run. The intention with this base class is that it can serve as a base for non-traditional tests.
Constructors
- TestRunner()
Initializes a new instance of the TestRunner<TContext, TTest> class.
Methods
- CreateTestClassInstance(TContext)
Override to creates and initialize the instance of the test class.
- DisposeTestClassInstance(TContext, object)
Disposes the test class instance. By default, will call DisposeAsync() if it's implemented, falling back to Dispose() if not.
- InvokeTest(TContext, object?)
Invokes the test method and returns the amount of time spent executing.
- InvokeTestMethod(TContext, object?)
Called by InvokeTest(TContext, object?) to invoke the test method.
- IsTestClassCreatable(TContext)
Override to determine whether a test class should be created.
- IsTestClassDisposable(TContext, object)
Determine whether a test class instance should be disposed. The pipeline will only call DisposeTestClassInstance(TContext, object) if this returns
true. By default, looks to see if the class implements IAsyncDisposable or IDisposable.
- OnTestClassConstructionFinished(TContext)
This method will be called when a test class instance has finished being constructed. By default, this sends TestClassConstructionFinished.
- OnTestClassConstructionStarting(TContext)
This method will be called when a test class instance is about to be constructed. By default, this sends TestClassConstructionStarting.
- OnTestClassDisposeFinished(TContext)
This method will be called when a test class instance has finished being disposed. By default, this sends TestClassDisposeFinished.
- OnTestClassDisposeStarting(TContext)
This method will be called when a test class instance is about to be disposed. By default, this sends TestClassDisposeStarting.
- PostInvoke(TContext)
Override this method to call code just after the test invocation has completed, but before the test class instance has been disposed.
- PreInvoke(TContext)
Override this method to call code just after the test class instance has been created, but before the test has been invoked.
- RunTest(TContext)
Override this method to run the test.