Class TestResult
The TestResult class represents the result of a test.
public abstract class TestResult : LongLivedMarshalByRefObject, ITestResult, IXmlNodeBuilder
- Inheritance
-
TestResult
- Implements
- Derived
- Inherited Members
Constructors
TestResult(ITest)
Construct a test result given a Test
public TestResult(ITest test)
Parameters
test
ITestThe test to be used
Fields
InternalAssertCount
Aggregate assertion count
protected int InternalAssertCount
Field Value
RwLock
ReaderWriterLock
protected ReaderWriterLockSlim RwLock
Field Value
Properties
AssertCount
Gets or sets the count of asserts executed when running the test.
public int AssertCount { get; }
Property Value
AssertionResults
Gets a list of assertion results associated with the test.
public IList<AssertionResult> AssertionResults { get; }
Property Value
Children
Gets the collection of child results.
public abstract IEnumerable<ITestResult> Children { get; }
Property Value
Duration
Gets or sets the elapsed time for running the test in seconds
public double Duration { get; set; }
Property Value
EndTime
Gets or sets the time the test finished running.
public DateTime EndTime { get; set; }
Property Value
FailCount
Gets the number of test cases that failed when running the test and all its children.
public abstract int FailCount { get; }
Property Value
FullName
Gets the full name of the test result
public virtual string FullName { get; }
Property Value
HasChildren
Indicates whether this result has any child results.
public abstract bool HasChildren { get; }
Property Value
InconclusiveCount
Gets the number of test cases that were inconclusive when running the test and all its children.
public abstract int InconclusiveCount { get; }
Property Value
Message
Gets the message associated with a test failure or with not running the test
public string Message { get; }
Property Value
Name
Gets the name of the test result
public virtual string Name { get; }
Property Value
OutWriter
Gets a TextWriter, which will write output to be included in the result.
public TextWriter OutWriter { get; }
Property Value
Output
Gets any text output written to this result.
public string Output { get; }
Property Value
PassCount
Gets the number of test cases that passed when running the test and all its children.
public abstract int PassCount { get; }
Property Value
PendingFailures
Gets a count of pending failures (from Multiple Assert)
public int PendingFailures { get; }
Property Value
ResultState
Gets the ResultState of the test result, which indicates the success or failure of the test.
public ResultState ResultState { get; }
Property Value
SkipCount
Gets the number of test cases that were skipped when running the test and all its children.
public abstract int SkipCount { get; }
Property Value
StackTrace
Gets any stack trace associated with an error or failure.
public virtual string? StackTrace { get; }
Property Value
StartTime
Gets or sets the time the test started running.
public DateTime StartTime { get; set; }
Property Value
Test
Gets the test with which this result is associated.
public ITest Test { get; }
Property Value
TestAttachments
Gets the collection of files attached to the test
public ICollection<TestAttachment> TestAttachments { get; }
Property Value
TotalCount
Gets the number of test cases executed when running the test and all its children.
public abstract int TotalCount { get; }
Property Value
WarningCount
Gets the number of test cases that had warnings when running the test and all its children.
public abstract int WarningCount { get; }
Property Value
WorstAssertionStatus
Gets the worst assertion status (highest enum) in all the assertion results
public AssertionStatus WorstAssertionStatus { get; }
Property Value
Methods
AddToXml(TNode, bool)
Adds the XML representation of the result as a child of the supplied parent node..
public virtual TNode AddToXml(TNode parentNode, bool recursive)
Parameters
Returns
RecordAssertion(AssertionResult)
Record an assertion result
public void RecordAssertion(AssertionResult assertion)
Parameters
assertion
AssertionResult
RecordAssertion(AssertionStatus, string)
Record an assertion result
public void RecordAssertion(AssertionStatus status, string message)
Parameters
status
AssertionStatusmessage
string
RecordAssertion(AssertionStatus, string, string?)
Record an assertion result
public void RecordAssertion(AssertionStatus status, string message, string? stackTrace)
Parameters
status
AssertionStatusmessage
stringstackTrace
string
RecordException(Exception)
Set the test result based on the type of exception thrown
public void RecordException(Exception ex)
Parameters
ex
ExceptionThe exception that was thrown
RecordException(Exception, FailureSite)
Set the test result based on the type of exception thrown
public void RecordException(Exception ex, FailureSite site)
Parameters
ex
ExceptionThe exception that was thrown
site
FailureSiteThe FailureSite to use in the result
RecordTearDownException(Exception)
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 RecordTearDownException(Exception ex)
Parameters
ex
ExceptionThe Exception to be recorded
RecordTestCompletion()
Update overall test result, including legacy Message, based on AssertionResults that have been saved to this point.
public void RecordTestCompletion()
SetResult(ResultState)
Set the result of the test
public void SetResult(ResultState resultState)
Parameters
resultState
ResultStateThe ResultState to use in the result
SetResult(ResultState, string)
Set the result of the test
public void SetResult(ResultState resultState, string message)
Parameters
resultState
ResultStateThe ResultState to use in the result
message
stringA message associated with the result state
SetResult(ResultState, string, string?)
Set the result of the test
public void SetResult(ResultState resultState, string message, string? stackTrace)
Parameters
resultState
ResultStateThe ResultState to use in the result
message
stringA message associated with the result state
stackTrace
stringStack trace giving the location of the command
ToXml(bool)
Returns the XML representation of the result.
public TNode ToXml(bool recursive)
Parameters
recursive
boolIf true, descendant results are included
Returns
- TNode
An XmlNode representing the result