Table of Contents

Method Find

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

Find(IMessageSink?, ITestFrameworkDiscoveryOptions, Func<ITestCase, bool>, 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>)). For runners which simply wish to discover and immediately run tests, they should instead use FindAndRun(IMessageSink, ITestFrameworkDiscoveryOptions, ITestFrameworkExecutionOptions, Func<ITestCase, bool>, Type[]?), which permits the same filtering logic as this method.

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

Parameters

messageSink

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>, Type[]?), so it is assumed that callers to this method will use the discoveryCallback to report discovered tests if needed.

options

The options to be used for discovery.

filter Func<ITestCase, bool>

The filter function for filtering test cases.

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