Class XunitTestFrameworkDiscoverer
The implementation of ITestFrameworkDiscoverer that supports discovery of unit tests linked against xunit.v3.core.dll.
public class XunitTestFrameworkDiscoverer : TestFrameworkDiscoverer<IXunitTestClass>, ITestFrameworkDiscoverer, IAsyncDisposable
- Inheritance
-
XunitTestFrameworkDiscoverer
- Implements
- Inherited Members
Constructors
XunitTestFrameworkDiscoverer(IXunitTestAssembly, IXunitTestCollectionFactory?)
Initializes a new instance of the XunitTestFrameworkDiscoverer class.
public XunitTestFrameworkDiscoverer(IXunitTestAssembly testAssembly, IXunitTestCollectionFactory? collectionFactory = null)
Parameters
testAssemblyIXunitTestAssemblyThe test assembly
collectionFactoryIXunitTestCollectionFactoryThe test collection factory used to look up test collections.
Properties
DiscovererTypeCache
Gets the mapping dictionary of fact attribute type to discoverer type. The key
is a type that implements IFactAttribute; the value is the
discoverer type, if known; null if not.
protected Dictionary<Type, Type?> DiscovererTypeCache { get; }
Property Value
TestAssembly
public IXunitTestAssembly TestAssembly { get; }
Property Value
TestCollectionFactory
Gets the test collection factory that makes test collections.
public IXunitTestCollectionFactory TestCollectionFactory { get; }
Property Value
Methods
CreateTestClass(Type)
Implement this method to create a test class for the given CLR type.
protected override ValueTask<IXunitTestClass> CreateTestClass(Type @class)
Parameters
classTypeThe CLR type.
Returns
- ValueTask<IXunitTestClass>
The test class.
Find(Func<ITestCase, ValueTask<bool>>, ITestFrameworkDiscoveryOptions, Type[]?, CancellationToken?)
Finds tests inside an assembly. Calls the callback for each discovered test.
public override ValueTask Find(Func<ITestCase, ValueTask<bool>> callback, ITestFrameworkDiscoveryOptions discoveryOptions, Type[]? types = null, CancellationToken? cancellationToken = null)
Parameters
callbackFunc<ITestCase, ValueTask<bool>>Called for each discovered test. Return
trueto continue test discovery; returnfalseto cancel test discovery.discoveryOptionsITestFrameworkDiscoveryOptionsThe options used by the test framework during 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.cancellationTokenCancellationToken?The optional cancellation token which can be used to cancel the test discovery process.
Returns
FindTestsForMethod(IXunitTestMethod, ITestFrameworkDiscoveryOptions, Func<ITestCase, ValueTask<bool>>)
Finds the tests on a test method.
protected virtual ValueTask<bool> FindTestsForMethod(IXunitTestMethod testMethod, ITestFrameworkDiscoveryOptions discoveryOptions, Func<ITestCase, ValueTask<bool>> discoveryCallback)
Parameters
testMethodIXunitTestMethodThe test method.
discoveryOptionsITestFrameworkDiscoveryOptionsThe options used by the test framework during discovery.
discoveryCallbackFunc<ITestCase, ValueTask<bool>>The callback that is called for each discovered test case.
Returns
FindTestsForType(IXunitTestClass, ITestFrameworkDiscoveryOptions, Func<ITestCase, ValueTask<bool>>)
Core implementation to discover unit tests in a given test class.
protected override ValueTask<bool> FindTestsForType(IXunitTestClass testClass, ITestFrameworkDiscoveryOptions discoveryOptions, Func<ITestCase, ValueTask<bool>> discoveryCallback)
Parameters
testClassIXunitTestClassThe test class.
discoveryOptionsITestFrameworkDiscoveryOptionsThe options used by the test framework during discovery.
discoveryCallbackFunc<ITestCase, ValueTask<bool>>The callback that is called for each discovered test case. The return value of the callback indicates the same thing as the return value of this function: return
trueto continue discovery, orfalseto halt it.
Returns
GetDiscoverer(Type)
Gets the test case discover instance for the given discoverer type. The instances are cached and reused, since they should not be stateful.
protected static IXunitTestCaseDiscoverer? GetDiscoverer(Type discovererType)
Parameters
discovererTypeTypeThe discoverer type.
Returns
- IXunitTestCaseDiscoverer
Returns the test case discoverer instance, if known; may return
nullwhen an error occurs (which is logged to the diagnostic message sink).
GetExportedTypes()
Override this to provide a list of the exported types in the assembly.
protected override Type[] GetExportedTypes()
Returns
- Type[]