Table of Contents

Class TestAssemblyRunnerContext<TTestAssembly, TTestCase>

Namespace
Xunit.v3
Assembly
xunit.v3.core.dll
public class TestAssemblyRunnerContext<TTestAssembly, TTestCase> : IAsyncLifetime, IAsyncDisposable where TTestAssembly : class, ITestAssembly where TTestCase : class, ITestCase

Type Parameters

TTestAssembly

The type of the test assembly object model. Must derive from ITestAssembly.

TTestCase

The 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)

public TestAssemblyRunnerContext(TTestAssembly testAssembly, IReadOnlyCollection<TTestCase> testCases, IMessageSink executionMessageSink, ITestFrameworkExecutionOptions executionOptions, CancellationToken cancellationToken)

Parameters

testAssembly TTestAssembly

The test assembly

testCases IReadOnlyCollection<TTestCase>

The test cases from the assembly

executionMessageSink IMessageSink

The message sink to send execution messages to

executionOptions ITestFrameworkExecutionOptions

The options used during test execution

cancellationToken CancellationToken

The cancellation token used to cancel execution

Properties

Aggregator

Gets the aggregator used for reporting exceptions.

public virtual ExceptionAggregator Aggregator { get; }

Property Value

ExceptionAggregator

CancellationTokenSource

Gets the cancellation token source used for cancelling test execution.

public virtual CancellationTokenSource CancellationTokenSource { get; }

Property Value

CancellationTokenSource

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

IMessageSink

ExecutionOptions

Gets the execution options provided by the runner.

protected ITestFrameworkExecutionOptions ExecutionOptions { get; }

Property Value

ITestFrameworkExecutionOptions

MessageBus

Gets the message bus to send execution engine messages to.

public IMessageBus MessageBus { get; }

Property Value

IMessageBus

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

string

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

string

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

ValueTask

InitializeAsync()

Called immediately after the class has been created, before it is used.

public virtual ValueTask InitializeAsync()

Returns

ValueTask