Class TestAssemblyRunnerContext<TTestAssembly, TTestCase>
Base context class for TestAssemblyRunner<TContext, TTestAssembly, TTestCollection, TTestCase>.
public class TestAssemblyRunnerContext<TTestAssembly, TTestCase> : IAsyncLifetime, IAsyncDisposable where TTestAssembly : class, ITestAssembly where TTestCase : class, ITestCase
Type Parameters
TTestAssemblyThe type of the test assembly object model. Must derive from ITestAssembly.
TTestCaseThe type of the test case used by the test framework. Must derive from ITestCase.
- Inheritance
-
TestAssemblyRunnerContext<TTestAssembly, TTestCase>
- Implements
- Derived
- Inherited Members
Constructors
TestAssemblyRunnerContext(TTestAssembly, IReadOnlyCollection<TTestCase>, IMessageSink, ITestFrameworkExecutionOptions, CancellationToken)
Base context class for TestAssemblyRunner<TContext, TTestAssembly, TTestCollection, TTestCase>.
public TestAssemblyRunnerContext(TTestAssembly testAssembly, IReadOnlyCollection<TTestCase> testCases, IMessageSink executionMessageSink, ITestFrameworkExecutionOptions executionOptions, CancellationToken cancellationToken)
Parameters
testAssemblyTTestAssemblyThe test assembly
testCasesIReadOnlyCollection<TTestCase>The test cases from the assembly
executionMessageSinkIMessageSinkThe message sink to send execution messages to
executionOptionsITestFrameworkExecutionOptionsThe options used during test execution
cancellationTokenCancellationTokenThe cancellation token used to cancel execution
Properties
Aggregator
Gets the aggregator used for reporting exceptions.
public virtual ExceptionAggregator Aggregator { get; }
Property Value
CancellationTokenSource
Gets the cancellation token source used for cancelling test execution.
public virtual CancellationTokenSource CancellationTokenSource { get; }
Property Value
ExecutionMessageSink
Gets the execution message sink provided by the runner. This is typically wrapped into the message bus by CreateMessageBus().
protected IMessageSink ExecutionMessageSink { get; }
Property Value
ExecutionOptions
Gets the execution options provided by the runner.
protected ITestFrameworkExecutionOptions ExecutionOptions { get; }
Property Value
MessageBus
Gets the message bus to send execution engine messages to.
public IMessageBus MessageBus { get; }
Property Value
TargetFramework
Gets the target framework that the test assembly is targeting. By default, this returns null.
Test frameworks that are based on .NET runtime assemblies can look for TargetFrameworkAttribute
decorated at the assembly level, which is added automatically by the compiler.
public virtual string? TargetFramework { get; }
Property Value
TestAssembly
Gets the assembly that is being executed.
public TTestAssembly TestAssembly { get; }
Property Value
- TTestAssembly
TestCases
Gets the test cases associated with this test assembly.
public IReadOnlyCollection<TTestCase> TestCases { get; protected set; }
Property Value
- IReadOnlyCollection<TTestCase>
TestEnvironment
Gets the environment that the test are running in. By default, returns a string which indicates process bitness, processor architecture (when known), and the description of the runtime environment (from FrameworkDescription).
public virtual string TestEnvironment { get; }
Property Value
Remarks
Example: "64-bit (x64) .NET 8.0.11"
Methods
CreateMessageBus()
Creates the message bus to be used for test execution. By default, it inspects the options for the SynchronousMessageReporting flag, and if present, creates a message bus that ensures all messages are delivered on the same thread.
protected virtual IMessageBus CreateMessageBus()
Returns
- IMessageBus
The message bus.
DisposeAsync()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources asynchronously.
public virtual ValueTask DisposeAsync()
Returns
InitializeAsync()
Called immediately after the class has been created, before it is used.
public virtual ValueTask InitializeAsync()