<PackageReference Include="NUnit" Version="3.13.3" />

TestResult

The TestResult class represents the result of a test.
protected int InternalAssertCount

Aggregate assertion count

ReaderWriterLock

public int AssertCount { get; }

Gets or sets the count of asserts executed when running the test.

Gets a list of assertion results associated with the test.

public abstract IEnumerable<ITestResult> Children { get; }

Gets the collection of child results.

public double Duration { get; set; }

Gets or sets the elapsed time for running the test in seconds

public DateTime EndTime { get; set; }

Gets or sets the time the test finished running.

public abstract int FailCount { get; }

Gets the number of test cases that failed when running the test and all its children.

public virtual string FullName { get; }

Gets the full name of the test result

public abstract bool HasChildren { get; }

Indicates whether this result has any child results.

public abstract int InconclusiveCount { get; }

Gets the number of test cases that were inconclusive when running the test and all its children.

public string Message { get; }

Gets the message associated with a test failure or with not running the test

public virtual string Name { get; }

Gets the name of the test result

public string Output { get; }

Gets any text output written to this result.

public TextWriter OutWriter { get; }

Gets a TextWriter, which will write output to be included in the result.

public abstract int PassCount { get; }

Gets the number of test cases that passed when running the test and all its children.

public int PendingFailures { get; }

Gets a count of pending failures (from Multiple Assert)

public ResultState ResultState { get; }

Gets the ResultState of the test result, which indicates the success or failure of the test.

public abstract int SkipCount { get; }

Gets the number of test cases that were skipped when running the test and all its children.

public virtual string StackTrace { get; }

Gets any stack trace associated with an error or failure.

public DateTime StartTime { get; set; }

Gets or sets the time the test started running.

public ITest Test { get; }

Gets the test with which this result is associated.

Gets the collection of files attached to the test

public abstract int TotalCount { get; }

Gets the number of test cases executed when running the test and all its children.

public abstract int WarningCount { get; }

Gets the number of test cases that had warnings when running the test and all its children.

Gets the worst assertion status (highest enum) in all the assertion results

public TestResult(ITest test)

Construct a test result given a Test

public virtual TNode AddToXml(TNode parentNode, bool recursive)

Adds the XML representation of the result as a child of the supplied parent node..

public void RecordAssertion(AssertionResult assertion)

Record an assertion result

public void RecordAssertion(AssertionStatus status, string message, string stackTrace)

Record an assertion result

public void RecordAssertion(AssertionStatus status, string message)

Record an assertion result

public void RecordException(Exception ex)

Set the test result based on the type of exception thrown

public void RecordException(Exception ex, FailureSite site)

Set the test result based on the type of exception thrown

RecordTearDownException appends the message and stack trace from an exception arising during teardown of the test to any previously recorded information, so that any earlier failure information is not lost. Note that calling Assert.Ignore, Assert.Inconclusive, etc. during teardown is treated as an error. If the current result represents a suite, it may show a teardown error even though all contained tests passed.

public void RecordTestCompletion()

Update overall test result, including legacy Message, based on AssertionResults that have been saved to this point.

public void SetResult(ResultState resultState)

Set the result of the test

public void SetResult(ResultState resultState, string message)

Set the result of the test

public void SetResult(ResultState resultState, string message, string stackTrace)

Set the result of the test

public TNode ToXml(bool recursive)

Returns the XML representation of the result.