Table of Contents

Class ResultState

Namespace
NUnit.Framework.Interfaces
Assembly
nunit.framework.dll

The ResultState class represents the outcome of running a test. It contains two pieces of information. The Status of the test is an enum indicating whether the test passed, failed, was skipped or was inconclusive. The Label provides a more detailed breakdown for use by client runners.

public class ResultState : IEquatable<ResultState>
Inheritance
ResultState
Implements
Inherited Members

Constructors

ResultState(TestStatus)

Initializes a new instance of the ResultState class.

public ResultState(TestStatus status)

Parameters

status TestStatus

The TestStatus.

ResultState(TestStatus, FailureSite)

Initializes a new instance of the ResultState class.

public ResultState(TestStatus status, FailureSite site)

Parameters

status TestStatus

The TestStatus.

site FailureSite

The stage at which the result was produced

ResultState(TestStatus, string?)

Initializes a new instance of the ResultState class.

public ResultState(TestStatus status, string? label)

Parameters

status TestStatus

The TestStatus.

label string

The label.

ResultState(TestStatus, string?, FailureSite)

Initializes a new instance of the ResultState class.

public ResultState(TestStatus status, string? label, FailureSite site)

Parameters

status TestStatus

The TestStatus.

label string

The label.

site FailureSite

The stage at which the result was produced

Fields

Cancelled

The test was cancelled by the user

public static readonly ResultState Cancelled

Field Value

ResultState

ChildFailure

A suite failed because one or more child tests failed or had errors

public static readonly ResultState ChildFailure

Field Value

ResultState

ChildIgnored

A suite is marked ignored because one or more child tests were ignored

public static readonly ResultState ChildIgnored

Field Value

ResultState

ChildWarning

A suite failed because one or more child tests had warnings

public static readonly ResultState ChildWarning

Field Value

ResultState

Error

The test encountered an unexpected exception

public static readonly ResultState Error

Field Value

ResultState

Explicit

The test was skipped because it is explicit

public static readonly ResultState Explicit

Field Value

ResultState

Failure

The test failed

public static readonly ResultState Failure

Field Value

ResultState

Ignored

The test has been ignored.

public static readonly ResultState Ignored

Field Value

ResultState

Inconclusive

The result is inconclusive

public static readonly ResultState Inconclusive

Field Value

ResultState

NotRunnable

The test was not runnable.

public static readonly ResultState NotRunnable

Field Value

ResultState

SetUpError

A suite had an unexpected exception in its OneTimeSetUp

public static readonly ResultState SetUpError

Field Value

ResultState

SetUpFailure

A suite failed in its OneTimeSetUp

public static readonly ResultState SetUpFailure

Field Value

ResultState

Skipped

The test has been skipped.

public static readonly ResultState Skipped

Field Value

ResultState

Success

The test succeeded

public static readonly ResultState Success

Field Value

ResultState

TearDownError

A suite had an unexpected exception in its OneTimeDown

public static readonly ResultState TearDownError

Field Value

ResultState

Warning

The test issued a warning

public static readonly ResultState Warning

Field Value

ResultState

Properties

Label

Gets the label under which this test result is categorized, or Empty if none.

public string Label { get; }

Property Value

string

Site

Gets the stage of test execution in which the failure or other result took place.

public FailureSite Site { get; }

Property Value

FailureSite

Status

Gets the TestStatus for the test.

public TestStatus Status { get; }

Property Value

TestStatus

The status.

Methods

Equals(ResultState?)

Indicates whether the current object is equal to another object of the same type.

public bool Equals(ResultState? other)

Parameters

other ResultState

An object to compare with this object.

Returns

bool

Equals(object?)

Determines whether the specified object is equal to the current object.

public override bool Equals(object? obj)

Parameters

obj object

The object to compare with the current object.

Returns

bool

GetHashCode()

Serves as the default hash function.

public override int GetHashCode()

Returns

int

Matches(ResultState)

Test whether this ResultState has the same Status and Label as another one. In other words, the whether two are equal ignoring the Site.

public bool Matches(ResultState other)

Parameters

other ResultState

Returns

bool

ToString()

Returns a string that represents this instance.

public override string ToString()

Returns

string

A string that represents this instance.

WithSite(FailureSite)

Get a new ResultState, which is the same as the current one but with the FailureSite set to the specified value.

public ResultState WithSite(FailureSite site)

Parameters

site FailureSite

The FailureSite to use

Returns

ResultState

A new ResultState

Operators

operator ==(ResultState?, ResultState?)

Overload == operator for ResultStates

public static bool operator ==(ResultState? left, ResultState? right)

Parameters

left ResultState
right ResultState

Returns

bool

operator !=(ResultState?, ResultState?)

Overload != operator for ResultStates

public static bool operator !=(ResultState? left, ResultState? right)

Parameters

left ResultState
right ResultState

Returns

bool