ResultState
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.
namespace NUnit.Framework.Interfaces
{
public class ResultState
{
private readonly TestStatus status;
private readonly string label;
public static readonly ResultState Inconclusive = new ResultState(TestStatus.Inconclusive);
public static readonly ResultState NotRunnable = new ResultState(TestStatus.Skipped, "Invalid");
public static readonly ResultState Skipped = new ResultState(TestStatus.Skipped);
public static readonly ResultState Ignored = new ResultState(TestStatus.Skipped, "Ignored");
public static readonly ResultState Success = new ResultState(TestStatus.Passed);
public static readonly ResultState Failure = new ResultState(TestStatus.Failed);
public static readonly ResultState Error = new ResultState(TestStatus.Failed, "Error");
public static readonly ResultState Cancelled = new ResultState(TestStatus.Failed, "Cancelled");
public TestStatus Status => status;
public string Label => label;
public ResultState(TestStatus status)
: this(status, string.Empty)
{
}
public ResultState(TestStatus status, string label)
{
this.status = status;
this.label = ((label == null) ? string.Empty : label);
}
public override string ToString()
{
string text = status.ToString();
if (label != null && label.Length != 0)
return $"{text}""{label}";
return text;
}
}
}