Table of Contents

Class TestCaseDiscovered

Namespace
Xunit.Runner.Common
Assembly
xunit.v3.runner.common.dll

Default implementation of ITestCaseDiscovered.

[JsonTypeID("test-case-discovered")]
public sealed class TestCaseDiscovered : TestCaseMessage, IJsonDeserializable, ITestCaseDiscovered, ITestCaseMessage, ITestMethodMessage, ITestClassMessage, ITestCollectionMessage, ITestAssemblyMessage, IMessageSinkMessage, IJsonSerializable, ITestCaseMetadata
Inheritance
TestCaseDiscovered
Implements
Inherited Members
Extension Methods

Properties

Explicit

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

public required bool Explicit { get; set; }

Property Value

bool

Remarks

Note: Will be false if there was no value provided during deserialization.

Serialization

Gets the serialized value of the test case, which allows it to be transferred across process boundaries.

public required string Serialization { get; set; }

Property Value

string

Remarks

Note: Will be UnsetStringPropertyValue if there was no value provided during deserialization.

SkipReason

Gets the display text for the reason a test is being skipped; if the test is not statically skipped, returns null. (A test may be dynamically skipped at runtime while still returning null.)

public required string? SkipReason { get; set; }

Property Value

string

Remarks

Note: Will be null if there was no value provided during deserialization.

SourceFilePath

Gets the source file name. A null value indicates that the source file name is not known.

public required string? SourceFilePath { get; set; }

Property Value

string

Remarks

Note: Will be null if there was no value provided during deserialization.

SourceLineNumber

Gets the source file line number. A null value indicates that the source file line number is not known.

public required int? SourceLineNumber { get; set; }

Property Value

int?

Remarks

Note: Will be null if there was no value provided during deserialization.

TestCaseDisplayName

Gets the display name of the test case.

public required string TestCaseDisplayName { get; set; }

Property Value

string

Remarks

Note: Will be UnsetStringPropertyValue if there was no value provided during deserialization.

TestClassMetadataToken

Gets the MetadataToken for the test class. If the test did not originate in a class, will return null.

public required int? TestClassMetadataToken { get; set; }

Property Value

int?

Remarks

This value is only populated for xUnit.net v3 or later test cases, and will return null for v1 or v2 test cases, regardless of whether TestClassName is null.

TestClassName

Gets the full name of the class where the test is defined (i.e., FullName). If the test did not originiate in a class, will return null.

public required string? TestClassName { get; set; }

Property Value

string

Remarks

Note: Will be null if there was no value provided during deserialization.

TestClassNamespace

Gets the namespace of the class where the test is defined. If the test did not originate in a class, or the class it originated in does not reside in a namespace, will return null.

public required string? TestClassNamespace { get; set; }

Property Value

string

Remarks

Note: Will be null if there was no value provided during deserialization.

TestClassSimpleName

Gets the simple name of the class where the test is defined (the class name without namespace). If the test did not originiate in a class, will return null.

public required string? TestClassSimpleName { get; set; }

Property Value

string

Remarks

Note: Will be null if there was no value provided during deserialization.

TestMethodMetadataToken

Gets the MetadataToken for the test method. If the test did not originate in a method, or the test framework did not provide this information, will return null.

public required int? TestMethodMetadataToken { get; set; }

Property Value

int?

Remarks

This value is only populated for xUnit.net v3 or later test cases, and will return null for v1 or v2 test cases, regardless of whether TestMethodName is null.

TestMethodName

Gets the method name where the test is defined, in the TestClassName class. If the test did not originiate in a method, will return null.

public required string? TestMethodName { get; set; }

Property Value

string

Remarks

Note: Will be null if there was no value provided during deserialization.

TestMethodParameterTypesVSTest

Gets the types for the test method parameters. If the test did not originate in a method, or the test framework does not provide this information, will return null; if the test method has no parameters, will return an empty array.

public required string[]? TestMethodParameterTypesVSTest { get; set; }

Property Value

string[]

Remarks

The values here are formatted according to VSTest rules in order to support Test Explorer. Note that this is not the same as FullName.

TestMethodReturnTypeVSTest

Gets the test method return type. If the test did not originate in a method, or the test framework did not provide this information, will return null.

public required string? TestMethodReturnTypeVSTest { get; set; }

Property Value

string

Remarks

The value here is formatted according to VSTest rules in order to support Test Explorer. Note that this is not the same as FullName.

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 required IReadOnlyDictionary<string, IReadOnlyCollection<string>> Traits { get; set; }

Property Value

IReadOnlyDictionary<string, IReadOnlyCollection<string>>

Remarks

Note: Will be an empty dictionary if there was no value provided during deserialization.

Methods

Deserialize(IReadOnlyDictionary<string, object?>)

Override to deserialize the values in the dictionary into the message.

protected override void Deserialize(IReadOnlyDictionary<string, object?> root)

Parameters

root IReadOnlyDictionary<string, object>

The root of the JSON object

Serialize(JsonObjectSerializer)

Override to serialize the values in the message into JSON.

protected override void Serialize(JsonObjectSerializer serializer)

Parameters

serializer JsonObjectSerializer

The serializer to write values to.

ToString()

public override string ToString()

Returns

string