Class InProcessFrontController
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
testFrameworkITestFrameworkThe test framework to be wrapped.
testAssemblyAssemblyThe assembly under test.
configFilePathstringThe optional configuration file path.
Properties
TestAssemblyUniqueID
Gets the unique ID for the test assembly provided to the discoverer.
public string TestAssemblyUniqueID { get; }
Property Value
TestFrameworkDisplayName
Returns the display name of the test framework that this discoverer is running tests for.
public string TestFrameworkDisplayName { get; }
Property Value
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
messageSinkIMessageSinkThe 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
discoveryCallbackto report discovered tests if needed.optionsITestFrameworkDiscoveryOptionsThe options to be used for discovery.
filterFunc<ITestCase, bool>The filter function for filtering test cases.
cancellationTokenSourceCancellationTokenSourceThe cancellation token source used to cancel discovery.
typesType[]When passed a non-
nullcollection, only returns tests found from one of the provided types; when passed anullcollection, discovers all tests in the assembly.discoveryCallbackFunc<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
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
messageSinkIMessageSinkThe message sink to report messages to.
discoveryOptionsITestFrameworkDiscoveryOptionsThe options to be used for discovery.
executionOptionsITestFrameworkExecutionOptionsThe options to be used for execution.
filterFunc<ITestCase, bool>The filter function for filtering test cases.
cancellationTokenSourceCancellationTokenSourceThe cancellation token sourced used to cancel discovery/execution.
typesType[]When passed a non-
nullcollection, discovery/filtering/execution only looks for tests from one of the provided types; when passed anullcollection, discovery/filtering/execution looks at all types in the assembly.
Returns
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
messageSinkIMessageSinkThe message sink to report messages to.
executionOptionsITestFrameworkExecutionOptionsThe options to be used for execution.
testCasesIReadOnlyCollection<ITestCase>The test cases to execute.
cancellationTokenSourceCancellationTokenSourceThe cancellation token source used to cancel discovery.