Class TestIntrospectionHelper
Helper functions for retrieving and interpreting test and test case details from various sources (like IFactAttribute, IDataAttribute, and others).
public static class TestIntrospectionHelper
- Inheritance
-
TestIntrospectionHelper
- Inherited Members
Methods
GetTestCaseDetails(ITestFrameworkDiscoveryOptions, IXunitTestMethod, IFactAttribute, object?[]?, int?, string?)
Retrieve the details for a test case that is a test method decorated with an instance of IFactAttribute (or derived).
public static (string TestCaseDisplayName, bool Explicit, Type[]? SkipExceptions, string? SkipReason, Type? SkipType, string? SkipUnless, string? SkipWhen, int Timeout, string UniqueID, IXunitTestMethod ResolvedTestMethod) GetTestCaseDetails(ITestFrameworkDiscoveryOptions discoveryOptions, IXunitTestMethod testMethod, IFactAttribute factAttribute, object?[]? testMethodArguments = null, int? timeout = null, string? baseDisplayName = null)
Parameters
discoveryOptionsITestFrameworkDiscoveryOptionsThe options used for discovery.
testMethodIXunitTestMethodThe test method.
factAttributeIFactAttributeThe fact attribute that decorates the test method.
testMethodArgumentsobject[]The optional test method arguments.
timeoutint?The optional timeout; if not provided, will be looked up from the
factAttribute.baseDisplayNamestringThe optional base display name for the test method.
Returns
- (string TestCaseDisplayName, bool Explicit, Type[] SkipExceptions, string SkipReason, Type SkipType, string SkipUnless, string SkipWhen, int Timeout, string UniqueID, IXunitTestMethod ResolvedTestMethod)
GetTestCaseDetailsForTheoryDataRow(ITestFrameworkDiscoveryOptions, IXunitTestMethod, ITheoryAttribute, ITheoryDataRow, object?[])
Retrieve the details for a test case that is a test method decorated with an instance of ITheoryAttribute (or derived) when you have a data row. The data row is used to augment the returned information (traits, skip reason, etc.).
public static (string TestCaseDisplayName, bool Explicit, Type[]? SkipExceptions, string? SkipReason, Type? SkipType, string? SkipUnless, string? SkipWhen, int Timeout, string UniqueID, IXunitTestMethod ResolvedTestMethod) GetTestCaseDetailsForTheoryDataRow(ITestFrameworkDiscoveryOptions discoveryOptions, IXunitTestMethod testMethod, ITheoryAttribute theoryAttribute, ITheoryDataRow dataRow, object?[] testMethodArguments)
Parameters
discoveryOptionsITestFrameworkDiscoveryOptionsThe options used for discovery.
testMethodIXunitTestMethodThe test method.
theoryAttributeITheoryAttributeThe theory attribute that decorates the test method.
dataRowITheoryDataRowThe data row for the test.
testMethodArgumentsobject[]The test method arguments obtained from the
dataRowafter being type-resolved.
Returns
- (string TestCaseDisplayName, bool Explicit, Type[] SkipExceptions, string SkipReason, Type SkipType, string SkipUnless, string SkipWhen, int Timeout, string UniqueID, IXunitTestMethod ResolvedTestMethod)
GetTraits(IXunitTestMethod, ITheoryDataRow?)
Merges the traits from the test method (which already reflect the traits from the test assembly, test collection, and test class) with the traits attached to the data row.
public static Dictionary<string, HashSet<string>> GetTraits(IXunitTestMethod testMethod, ITheoryDataRow? dataRow)
Parameters
testMethodIXunitTestMethodThe test method to get traits from.
dataRowITheoryDataRowThe data row to get traits from.
Returns
- Dictionary<string, HashSet<string>>
The traits dictionary
MergeTraitsInto(Dictionary<string, HashSet<string>>, string[]?)
Merges string-array traits (like from Traits) into an existing traits dictionary.
public static void MergeTraitsInto(Dictionary<string, HashSet<string>> traits, string[]? additionalTraits)
Parameters
traitsDictionary<string, HashSet<string>>The existing traits dictionary.
additionalTraitsstring[]The additional traits to merge.