Table of Contents

Class TestResultState

Namespace
Xunit
Assembly
xunit.v3.core.dll

Represents information about the current state of a test after it has run.

public class TestResultState
Inheritance
TestResultState
Inherited Members

Properties

ExceptionMessages

Gets the message(s) of the exception(s). This value is only available when Result is Failed.

public string[]? ExceptionMessages { get; }

Property Value

string[]

ExceptionParentIndices

Gets the parent exception index(es) for the exception(s); a -1 indicates that the exception in question has no parent. This value is only available when Result is Failed.

public int[]? ExceptionParentIndices { get; }

Property Value

int[]

ExceptionStackTraces

Gets the stack trace(s) of the exception(s). This value is only available when Result is Failed.

public string?[]? ExceptionStackTraces { get; }

Property Value

string[]

ExceptionTypes

Gets the fully-qualified type name(s) of the exception(s). This value is only available when Result is Failed.

public string?[]? ExceptionTypes { get; }

Property Value

string[]

ExecutionTime

Gets the amount of time the test ran, in seconds. The value may be 0 if no test code was run (for example, a statically skipped test). Note that the value may be a partial value because of further timing being done while cleaning up.

public decimal? ExecutionTime { get; }

Property Value

decimal?

FailureCause

Gets a value which indicates what the cause of the test failure was. This value is only available when Result is Failed.

public FailureCause? FailureCause { get; }

Property Value

FailureCause?

Result

Returns the result from the test run.

public TestResult Result { get; }

Property Value

TestResult

Methods

ForNotRun(decimal?)

Create a not run test result.

public static TestResultState ForNotRun(decimal? executionTime = null)

Parameters

executionTime decimal?

The optional execution time

Returns

TestResultState

ForPassed(decimal?)

Create a passing test result.

public static TestResultState ForPassed(decimal? executionTime = null)

Parameters

executionTime decimal?

The optional execution time

Returns

TestResultState

ForSkipped(decimal?)

Create a skipped test result.

public static TestResultState ForSkipped(decimal? executionTime = null)

Parameters

executionTime decimal?

The optional execution time

Returns

TestResultState

FromException(decimal, Exception?)

Creates an instance based on the presence or absence of an exception. If the exception is null, then it will be for Passed; otherwise, it will be for Failed;

public static TestResultState FromException(decimal executionTime, Exception? exception)

Parameters

executionTime decimal

The time spent executing the test

exception Exception

The exception, if the test failed

Returns

TestResultState

FromTestResult(ITestResultMessage)

Creates an instance based on inspecting the type identity of the testResult instance.

public static TestResultState FromTestResult(ITestResultMessage testResult)

Parameters

testResult ITestResultMessage

The test result

Returns

TestResultState