Table of Contents

Class TestFailed

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

Default implementation of ITestFailed.

[JsonTypeID("test-failed")]
public sealed class TestFailed : TestResultMessage, IJsonDeserializable, ITestFailed, ITestResultMessage, ITestMessage, ITestCaseMessage, ITestMethodMessage, ITestClassMessage, ITestCollectionMessage, ITestAssemblyMessage, IMessageSinkMessage, IJsonSerializable, IExecutionMetadata, IErrorMetadata
Inheritance
TestFailed
Implements
Inherited Members
Extension Methods

Properties

Cause

Gets the cause of the test failure.

public required FailureCause Cause { get; set; }

Property Value

FailureCause

Remarks

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

ExceptionParentIndices

Gets the parent exception index(es) for the exception(s); a -1 indicates that the exception in question has no parent.

public required int[] ExceptionParentIndices { get; set; }

Property Value

int[]

Remarks

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

ExceptionTypes

Gets the fully-qualified type name(s) of the exception(s).

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

Property Value

string[]

Remarks

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

Messages

Gets the message(s) of the exception(s).

public required string[] Messages { get; set; }

Property Value

string[]

Remarks

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

StackTraces

Gets the stack trace(s) of the exception(s).

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

Property Value

string[]

Remarks

Note: Will be an empty array 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

FromException(Exception, string, string, string?, string?, string, string, decimal, string?, string[]?, DateTimeOffset?)

Creates a new ITestFailed constructed from an Exception object.

public static ITestFailed FromException(Exception ex, string assemblyUniqueID, string testCollectionUniqueID, string? testClassUniqueID, string? testMethodUniqueID, string testCaseUniqueID, string testUniqueID, decimal executionTime, string? output, string[]? warnings, DateTimeOffset? finishTime = null)

Parameters

ex Exception

The exception to use

assemblyUniqueID string

The unique ID of the assembly

testCollectionUniqueID string

The unique ID of the test collectioon

testClassUniqueID string

The (optional) unique ID of the test class

testMethodUniqueID string

The (optional) unique ID of the test method

testCaseUniqueID string

The unique ID of the test case

testUniqueID string

The unique ID of the test

executionTime decimal

The execution time of the test (may be null if the test wasn't executed)

output string

The (optional) output from the test

warnings string[]

The (optional) warnings that were recorded during test execution

finishTime DateTimeOffset?

The time when the test finished executing; defaults to UtcNow

Returns

ITestFailed

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