Class TestResult
The TestResult class represents the result of a test.
public abstract class TestResult : 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
CHILD_ERRORS_MESSAGE
Error message for when child tests have errors
public static readonly string CHILD_ERRORS_MESSAGE
Field Value
CHILD_IGNORE_MESSAGE
Error message for when child tests are ignored
public static readonly string CHILD_IGNORE_MESSAGE
Field Value
Properties
AssertCount
Gets or sets the count of asserts executed when running the test.
public int AssertCount { get; set; }
Property Value
Children
Gets the collection of child results.
public IList<ITestResult> Children { get; }
Property Value
Duration
Gets or sets the elapsed time for running the test
public TimeSpan 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. Test HasChildren before accessing Children to avoid the creation of an empty collection.
public 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 StringWriter 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
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 stacktrace 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
Methods
AddResult(ITestResult)
Adds a child result to this result, setting this result's ResultState to Failure if the child result failed.
public virtual void AddResult(ITestResult result)
Parameters
result
ITestResultThe result to be added
AddToXml(XmlNode, bool)
Adds the XML representation of the result as a child of the supplied parent node..
public virtual XmlNode AddToXml(XmlNode parentNode, bool recursive)
Parameters
Returns
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 stacktrace 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
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 XmlNode ToXml(bool recursive)
Parameters
recursive
boolIf true, descendant results are included
Returns
- XmlNode
An XmlNode representing the result