Table of Contents

Class TestIntrospectionHelper

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

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

discoveryOptions ITestFrameworkDiscoveryOptions

The options used for discovery.

testMethod IXunitTestMethod

The test method.

factAttribute IFactAttribute

The fact attribute that decorates the test method.

testMethodArguments object[]

The optional test method arguments.

timeout int?

The optional timeout; if not provided, will be looked up from the factAttribute.

baseDisplayName string

The 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

discoveryOptions ITestFrameworkDiscoveryOptions

The options used for discovery.

testMethod IXunitTestMethod

The test method.

theoryAttribute ITheoryAttribute

The theory attribute that decorates the test method.

dataRow ITheoryDataRow

The data row for the test.

testMethodArguments object[]

The test method arguments obtained from the dataRow after 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

testMethod IXunitTestMethod

The test method to get traits from.

dataRow ITheoryDataRow

The 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

traits Dictionary<string, HashSet<string>>

The existing traits dictionary.

additionalTraits string[]

The additional traits to merge.