Class XunitTest
An implementation of ITest for xUnit v3.
public class XunitTest : IXunitTest, ITest, ITestMetadata
- Inheritance
-
XunitTest
- Implements
- Inherited Members
Constructors
XunitTest(IXunitTestCase, IXunitTestMethod, bool?, string?, string, int, IReadOnlyDictionary<string, IReadOnlyCollection<string>>, int?, object?[])
Initializes a new instance of the XunitTest class.
public XunitTest(IXunitTestCase testCase, IXunitTestMethod testMethod, bool? @explicit, string? skipReason, string testDisplayName, int testIndex, IReadOnlyDictionary<string, IReadOnlyCollection<string>> traits, int? timeout, object?[] testMethodArguments)
Parameters
testCaseIXunitTestCaseThe test case this test belongs to.
testMethodIXunitTestMethodThe test method to be run; may differ from the test method embedded into the test case
explicitbool?A flag to indicate the test was marked as explicit; if not set, will fall back to the test case
skipReasonstringThe skip reason for this test.
testDisplayNamestringThe display name for this test.
testIndexintThe index of this test inside the test case. Used for computing UniqueID.
traitsIReadOnlyDictionary<string, IReadOnlyCollection<string>>The traits for the given test.
timeoutint?The timeout for the test; if not set, will fall back to the test case
testMethodArgumentsobject[]The arguments to be passed to the test method
XunitTest(IXunitTestCase, IXunitTestMethod, bool?, string?, string, string, IReadOnlyDictionary<string, IReadOnlyCollection<string>>?, int?, object?[]?)
This constructor is for testing purposes only. Do not use in production code.
public XunitTest(IXunitTestCase testCase, IXunitTestMethod testMethod, bool? @explicit, string? skipReason, string testDisplayName, string uniqueID, IReadOnlyDictionary<string, IReadOnlyCollection<string>>? traits = null, int? timeout = null, object?[]? testMethodArguments = null)
Parameters
testCaseIXunitTestCasetestMethodIXunitTestMethodexplicitbool?skipReasonstringtestDisplayNamestringuniqueIDstringtraitsIReadOnlyDictionary<string, IReadOnlyCollection<string>>timeoutint?testMethodArgumentsobject[]
Properties
Explicit
Gets a flag indicating whether this test was marked as explicit or not.
public bool Explicit { get; }
Property Value
SkipReason
Gets a skip reason for this test.
public string? SkipReason { get; }
Property Value
Remarks
This value may not line up the with SkipReason, as you can skip individual data rows during delay enumeration.
TestCase
Gets the xUnit v3 test case.
public IXunitTestCase TestCase { get; }
Property Value
TestDisplayName
Gets the display name of the test.
public string TestDisplayName { get; }
Property Value
TestMethod
Gets the test method to run. May different from the test method embedded in the test case.
public IXunitTestMethod TestMethod { get; }
Property Value
TestMethodArguments
Gets the arguments to be passed to the test method during invocation.
public object?[] TestMethodArguments { get; }
Property Value
- object[]
Timeout
Gets the timeout for the test, in milliseconds; if 0, there is no timeout.
public int Timeout { get; }
Property Value
Remarks
WARNING: Using this with Aggressive will result in undefined behavior. Timeout is only supported by Conservative (or when parallelization is disabled completely).
Traits
Gets the trait values associated with this test case. If
there are none, or the framework does not support traits,
this should return an empty dictionary (not null).
public IReadOnlyDictionary<string, IReadOnlyCollection<string>> Traits { get; }
Property Value
UniqueID
Gets a unique identifier for the test.
public string UniqueID { get; }
Property Value
Remarks
The unique identifier for a test should be able to discriminate among test, even those which are varied invocations against the same test method (i.e., theories). This identifier should remain stable until such time as the developer changes some fundamental part of the identity (assembly, class name, test name, or test data). Recompilation of the test assembly is reasonable as a stability changing event.