Table of Contents

Class XunitTest

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

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

testCase IXunitTestCase

The test case this test belongs to.

testMethod IXunitTestMethod

The test method to be run; may differ from the test method embedded into the test case

explicit bool?

A flag to indicate the test was marked as explicit; if not set, will fall back to the test case

skipReason string

The skip reason for this test.

testDisplayName string

The display name for this test.

testIndex int

The index of this test inside the test case. Used for computing UniqueID.

traits IReadOnlyDictionary<string, IReadOnlyCollection<string>>

The traits for the given test.

timeout int?

The timeout for the test; if not set, will fall back to the test case

testMethodArguments object[]

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

testCase IXunitTestCase
testMethod IXunitTestMethod
explicit bool?
skipReason string
testDisplayName string
uniqueID string
traits IReadOnlyDictionary<string, IReadOnlyCollection<string>>
timeout int?
testMethodArguments object[]

Properties

Explicit

Gets a flag indicating whether this test was marked as explicit or not.

public bool Explicit { get; }

Property Value

bool

SkipReason

Gets a skip reason for this test.

public string? SkipReason { get; }

Property Value

string

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

IXunitTestCase

TestDisplayName

Gets the display name of the test.

public string TestDisplayName { get; }

Property Value

string

TestMethod

Gets the test method to run. May different from the test method embedded in the test case.

public IXunitTestMethod TestMethod { get; }

Property Value

IXunitTestMethod

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

int

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

IReadOnlyDictionary<string, IReadOnlyCollection<string>>

UniqueID

Gets a unique identifier for the test.

public string UniqueID { get; }

Property Value

string

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.