Class TheoryDiscoverer
Implementation of IXunitTestCaseDiscoverer that supports finding test cases on methods decorated with ITheoryAttribute.
public class TheoryDiscoverer : IXunitTestCaseDiscoverer
- Inheritance
-
TheoryDiscoverer
- Implements
- Inherited Members
Methods
CreateTestCasesForDataRow(ITestFrameworkDiscoveryOptions, IXunitTestMethod, ITheoryAttribute, ITheoryDataRow, object?[])
Creates test cases for a single row of data. By default, returns a single instance of XunitTestCase with the data row inside of it.
protected virtual ValueTask<IReadOnlyCollection<IXunitTestCase>> CreateTestCasesForDataRow(ITestFrameworkDiscoveryOptions discoveryOptions, IXunitTestMethod testMethod, ITheoryAttribute theoryAttribute, ITheoryDataRow dataRow, object?[] testMethodArguments)
Parameters
discoveryOptionsITestFrameworkDiscoveryOptionsThe discovery options to be used.
testMethodIXunitTestMethodThe test method the test cases belong to.
theoryAttributeITheoryAttributeThe theory attribute attached to the test method.
dataRowITheoryDataRowThe data row that generated
testMethodArguments.testMethodArgumentsobject[]The arguments for the test method.
Returns
- ValueTask<IReadOnlyCollection<IXunitTestCase>>
The test cases
CreateTestCasesForTheory(ITestFrameworkDiscoveryOptions, IXunitTestMethod, ITheoryAttribute)
Creates test cases for the entire theory. This is used when one or more of the theory data items are not serializable, or if the user has requested to skip theory pre-enumeration, or if the user has requested the entire theory be skipped. By default, returns a single instance of XunitDelayEnumeratedTheoryTestCase (which performs the data discovery at runtime, for non-skipped theories) or XunitTestCase (for skipped theories).
protected virtual ValueTask<IReadOnlyCollection<IXunitTestCase>> CreateTestCasesForTheory(ITestFrameworkDiscoveryOptions discoveryOptions, IXunitTestMethod testMethod, ITheoryAttribute theoryAttribute)
Parameters
discoveryOptionsITestFrameworkDiscoveryOptionsThe discovery options to be used.
testMethodIXunitTestMethodThe test method the test cases belong to.
theoryAttributeITheoryAttributeThe theory attribute attached to the test method.
Returns
- ValueTask<IReadOnlyCollection<IXunitTestCase>>
The test case
Discover(ITestFrameworkDiscoveryOptions, IXunitTestMethod, IFactAttribute)
Discover test cases from a test method.
public virtual ValueTask<IReadOnlyCollection<IXunitTestCase>> Discover(ITestFrameworkDiscoveryOptions discoveryOptions, IXunitTestMethod testMethod, IFactAttribute factAttribute)
Parameters
discoveryOptionsITestFrameworkDiscoveryOptionsThe discovery options to be used.
testMethodIXunitTestMethodThe test method the test cases belong to.
factAttributeIFactAttributeThe theory attribute attached to the test method.
Returns
- ValueTask<IReadOnlyCollection<IXunitTestCase>>
Returns zero or more test cases represented by the test method.
Remarks
This method performs the following steps:
- If the theory attribute is marked with Skip, or pre-enumeration is off, or any of the test data is non serializable,
returns the result of CreateTestCasesForTheory(ITestFrameworkDiscoveryOptions, IXunitTestMethod, ITheoryAttribute);
- If there is no theory data, returns a single test case of ExecutionErrorTestCase with the error in it;
- Otherwise, it returns one test case per data row, created by calling CreateTestCasesForDataRow(ITestFrameworkDiscoveryOptions, IXunitTestMethod, ITheoryAttribute, ITheoryDataRow, object?[]).