Table of Contents

Class InProcessFrontController

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

This class is a "philosophical" implementation of IFrontController (which isn't a type that's available here), intended to be used by in-process runners, wrapped around an implementation of ITestFramework. The signatures of the methods are slightly different, as they permit and require direct access to ITestCase instances rather than forcing the test cases through a round of serialization and deserialization. It will also manufacture the IDiscoveryStarting and IDiscoveryComplete messages that the test framework is not responsible for. When connected to remote meta-runners, the in-process runner can convert ITestCase instances into TestCaseDiscovered instances by using a converter like Xunit.Runner.Common.TestCaseExtensions.ToTestCaseDiscovered (which should be called from a callback passed to Find(IMessageSink?, ITestFrameworkDiscoveryOptions, Func<ITestCase, bool>, CancellationTokenSource, Type[]?, Func<ITestCase, bool, ValueTask<bool>>?)).

public class InProcessFrontController
Inheritance
InProcessFrontController
Inherited Members

Constructors

InProcessFrontController(ITestFramework, Assembly, string?)

Initializes a new instance of the InProcessFrontController class.

public InProcessFrontController(ITestFramework testFramework, Assembly testAssembly, string? configFilePath)

Parameters

testFramework ITestFramework

The test framework to be wrapped.

testAssembly Assembly

The assembly under test.

configFilePath string

The optional configuration file path.

Properties

TestAssemblyUniqueID

Gets the unique ID for the test assembly provided to the discoverer.

public string TestAssemblyUniqueID { get; }

Property Value

string

TestFrameworkDisplayName

Returns the display name of the test framework that this discoverer is running tests for.

public string TestFrameworkDisplayName { get; }

Property Value

string

Methods

Find(IMessageSink?, ITestFrameworkDiscoveryOptions, Func<ITestCase, bool>, CancellationTokenSource, Type[]?, Func<ITestCase, bool, ValueTask<bool>>?)

Starts the process of finding tests in an assembly. Typically only used by runners which discover tests and present them into a UI for the user to interactively choose for selective run (via Run(IMessageSink, ITestFrameworkExecutionOptions, IReadOnlyCollection<ITestCase>, CancellationTokenSource)). For runners which simply wish to discover and immediately run tests, they should instead use FindAndRun(IMessageSink, ITestFrameworkDiscoveryOptions, ITestFrameworkExecutionOptions, Func<ITestCase, bool>, CancellationTokenSource, Type[]?), which permits the same filtering logic as this method.

public ValueTask Find(IMessageSink? messageSink, ITestFrameworkDiscoveryOptions options, Func<ITestCase, bool> filter, CancellationTokenSource cancellationTokenSource, Type[]? types = null, Func<ITestCase, bool, ValueTask<bool>>? discoveryCallback = null)

Parameters

messageSink IMessageSink

The message sink to report discovery starting and discovery complete messages to. Discovered tests are not reported to this message sink, since it's also used for FindAndRun(IMessageSink, ITestFrameworkDiscoveryOptions, ITestFrameworkExecutionOptions, Func<ITestCase, bool>, CancellationTokenSource, Type[]?), so it is assumed that callers to this method will use the discoveryCallback to report discovered tests if needed.

options ITestFrameworkDiscoveryOptions

The options to be used for discovery.

filter Func<ITestCase, bool>

The filter function for filtering test cases.

cancellationTokenSource CancellationTokenSource

The cancellation token source used to cancel discovery.

types Type[]

When passed a non-null collection, only returns tests found from one of the provided types; when passed a null collection, discovers all tests in the assembly.

discoveryCallback Func<ITestCase, bool, ValueTask<bool>>

An optional callback to be called for each discovered test case. It provides both the test case and a flag which indicates if it passed the provided filter.

Returns

ValueTask

FindAndRun(IMessageSink, ITestFrameworkDiscoveryOptions, ITestFrameworkExecutionOptions, Func<ITestCase, bool>, CancellationTokenSource, Type[]?)

Starts the process of finding and running tests in an assembly. Typically only used by runner which do not present test discovery UIs to users that allow them to run selected tests (those should instead use Find(IMessageSink?, ITestFrameworkDiscoveryOptions, Func<ITestCase, bool>, CancellationTokenSource, Type[]?, Func<ITestCase, bool, ValueTask<bool>>?) and Run(IMessageSink, ITestFrameworkExecutionOptions, IReadOnlyCollection<ITestCase>, CancellationTokenSource) as separate operations).

public ValueTask FindAndRun(IMessageSink messageSink, ITestFrameworkDiscoveryOptions discoveryOptions, ITestFrameworkExecutionOptions executionOptions, Func<ITestCase, bool> filter, CancellationTokenSource cancellationTokenSource, Type[]? types = null)

Parameters

messageSink IMessageSink

The message sink to report messages to.

discoveryOptions ITestFrameworkDiscoveryOptions

The options to be used for discovery.

executionOptions ITestFrameworkExecutionOptions

The options to be used for execution.

filter Func<ITestCase, bool>

The filter function for filtering test cases.

cancellationTokenSource CancellationTokenSource

The cancellation token sourced used to cancel discovery/execution.

types Type[]

When passed a non-null collection, discovery/filtering/execution only looks for tests from one of the provided types; when passed a null collection, discovery/filtering/execution looks at all types in the assembly.

Returns

ValueTask

Run(IMessageSink, ITestFrameworkExecutionOptions, IReadOnlyCollection<ITestCase>, CancellationTokenSource)

Starts the process of running selected tests in the assembly. The test cases to run come from calling Find(IMessageSink?, ITestFrameworkDiscoveryOptions, Func<ITestCase, bool>, CancellationTokenSource, Type[]?, Func<ITestCase, bool, ValueTask<bool>>?) and collecting the test cases that were returned via the callback.

public ValueTask Run(IMessageSink messageSink, ITestFrameworkExecutionOptions executionOptions, IReadOnlyCollection<ITestCase> testCases, CancellationTokenSource cancellationTokenSource)

Parameters

messageSink IMessageSink

The message sink to report messages to.

executionOptions ITestFrameworkExecutionOptions

The options to be used for execution.

testCases IReadOnlyCollection<ITestCase>

The test cases to execute.

cancellationTokenSource CancellationTokenSource

The cancellation token source used to cancel discovery.

Returns

ValueTask