gambas-source-code/OriginalFiles/manual/testresult.html
Christof Thalhofer 5111def64b Unittest weiter
2015-10-31 09:22:52 +01:00

373 lines
12 KiB
HTML

<html>
<head>
<title>COMUnit Reference Manual: TestResult</title>
</head>
<body>
<h1>Class TestResult</h1>
<h2>Description:</h2>
<p>
The TestResult object collects the results from executing test cases. It is an
instance of the Collecting Parameter pattern. When new failures or errors
are added to the TestResult or if a test case is started or finished, the
TestResult generates events to notify its event handlers about what has happened.
</p>
<p>The test framework distinguishes between failures and errors.
A failure is anticipated and checked for with assertions. Errors are
unanticipated problems signified by errors that are raised while executing the test code.
TestResult includes a set of Assert methods that simplify
the checking of test assertions.
</p>
<h2>Interface Implementation:</h2>
<ul>
<li>None</li>
</ul>
<h2>Known Subclasses:</h2>
<ul>
<li>None</li>
</ul>
<h2>Method Summary:</h2>
<table border="1" cellpadding="2" cellspacing="2">
<tr><th>Method:</th><th>Definition:</th></tr>
<tr>
<td><a href="#Assert">Assert</a></td>
<td>Public Sub Assert(bCondition As Boolean, Optional sMessage As String)</td>
</tr>
<tr>
<td><a href="#AssertEqualsDouble">AssertEqualsDouble</a></td>
<td>Public Sub AssertEqualsDouble(dExpected As Double, dActual As Double, dDelta As Double, Optional sMessage As String)</td>
</tr>
<tr>
<td><a href="#AssertEqualsError">AssertEqualsError</a></td>
<td>Public Sub AssertEqualsError(oError As ErrObject, Optional lError As Long, Optional sMessage As String)</td>
</tr>
<tr>
<td><a href="#AssertEqualsLong">AssertEqualsLong</a></td>
<td>Public Sub AssertEqualsLong(lExpected As Long, lActual As Long, Optional sMessage As String)</td>
</tr>
<tr>
<td><a href="#AssertEqualsObject">AssertEqualsObject</a></td>
<td>Public Sub AssertEqualsObject(oExpected As Object, oActual As Object, Optional sMessage As String)</td>
</tr>
<tr>
<td><a href="#AssertEqualsString">AssertEqualsString</a></td>
<td>Public Sub AssertEqualsString(sExpected As String, sActual As String, Optional sMessage As String)</td>
</tr>
<tr>
<td><a href="#AssertEqualsVariant">AssertEqualsVariant</a></td>
<td>Public Sub AssertEqualsVariant(vExpected As Variant, vActual As Variant, Optional sMessage As String)</td>
</tr>
<tr>
<td><a href="#AssertExists">AssertExists</a></td>
<td>Public Sub AssertExists(oObject As Object, Optional sMessage As String)</td>
</tr>
<tr>
<td><a href="#AssertNotEmpty">AssertNotEmpty</a></td>
<td>Public Sub AssertNotEmpty(vVariant As Variant, Optional sMessage As String)</td>
</tr>
<tr>
<td><a href="#AssertNotNull">AssertNotNull</a></td>
<td>Public Sub AssertNotNull(vVariant As Variant, Optional sMessage As String)</td>
</tr>
<tr>
<td><a href="#AddError">AddError</a></td>
<td>Public Sub AddError(lNumber As Long, sSource As String, sDescription As String)</td>
</tr>
<tr>
<td><a href="#AddFailure">AddFailure</a></td>
<td>Public Sub AddFailure(sDescription As String)</td>
</tr>
<tr>
<td><a href="#AddTrace">AddTrace</a></td>
<td>Public Sub AddTrace(sMessage As String)</td>
</tr>
<tr>
<td><a href="#EndTest">EndTest</a></td>
<td>Public Sub EndTest()</td>
</tr>
<tr>
<td><a href="#Errors">Errors</a></td>
<td>Public Property Get Errors() As TestErrors</td>
</tr>
<tr>
<td><a href="#Failures">Failures</a></td>
<td>Public Property Get Failures() As TestErrors</td>
</tr>
<tr>
<td><a href="#Parameters">Parameters</a></td>
<td>Public Property Get Parameters() As TestParameters<br />
Public Property Set Parameters(colParameters As TestParameters)</td>
</tr>
<tr>
<td><a href="#Run">Run</a></td>
<td>Public Sub Run(ByRef oTestResult As TestResult)</td>
</tr>
<tr>
<td><a href="#RunTests">RunTests</a></td>
<td>Public Property Get RunTests() As Integer</td>
</tr>
<tr>
<td><a href="#StartTest">StartTest</a></td>
<td>Public Sub StartTest(oTestCase As ITestCase)</td>
</tr>
<tr>
<td><a href="#WasSuccessful">WasSuccessful</a></td>
<td>Public Property Get WasSuccessful() As Boolean</td>
</tr>
</table>
<h2>Event Summary:</h2>
<table border="1" cellpadding="2" cellspacing="2">
<tr><th>Event:</th><th>Definition:</th></tr>
<tr>
<td><a href="#AfterStartTest">AfterStartTest</a></td>
<td>Public Event AfterStartTest(oTestCase As ITestCase)</td>
</tr>
<tr>
<td><a href="#AfterEndTest">AfterEndTest</a></td>
<td>Public Event AfterEndTest()</td>
</tr>
<tr>
<td><a href="#AfterAddError">AfterAddError</a></td>
<td>Public Event AfterAddError(oError As TestError)</td>
</tr>
<tr>
<td><a href="#AfterAddFailure">AfterAddFailure</a></td>
<td>Public Event AfterAddFailure(oError As TestError)</td>
</tr>
<tr>
<td><a href="#AfterAddTrace">AfterAddTrace</a></td>
<td>Public Event AfterAddTrace(sMessage As String)</td>
</tr>
</table>
<h2>Methods:</h2>
<h3><a name="WasSuccessful">WasSuccessful</a></h3>
<dl>
<dt>Definition:</dt><dd>Public Property Get WasSuccessful() As Boolean</dd>
<dt>Description:</dt><dd>Returns whether the entire test was successful or not.</dd>
</dl>
<hr />
<h3><a name="StartTest">StartTest</a></h3>
<dl>
<dt>Definition:</dt><dd>Public Sub StartTest(oTestCase As ITestCase)</dd>
<dt>Description:</dt><dd>Informs the result that a test will be started.</dd>
</dl>
<hr />
<h3><a name="EndTest">EndTest</a></h3>
<dl>
<dt>Definition:</dt><dd>Public Sub EndTest()</dd>
<dt>Description:</dt><dd>Informs the result that a test is completed.</dd>
</dl>
<hr />
<h3><a name="AddFailure">AddFailure</a></h3>
<dl>
<dt>Definition:</dt><dd>Public Sub AddFailure(sDescription As String)</dd>
<dt>Description:</dt><dd>Adds a failure to the collection of failures.</dd>
</dl>
<hr />
<h3><a name="AddError">AddError</a></h3>
<dl>
<dt>Definition:</dt><dd>Public Sub AddError(lNumber As Long, sSource As String, sDescription As String)</dd>
<dt>Description:</dt><dd>Adds a error to the collection of errors.</dd>
</dl>
<hr />
<h3><a name="AddTrace">AddTrace</a></h3>
<dl>
<dt>Definition:</dt><dd>Public Sub AddTrace(sMessage As String)</dd>
<dt>Description:</dt><dd>Add trace message</dd>
</dl>
<hr />
<h3><a name="RunTests">RunTests</a></h3>
<dl>
<dt>Definition:</dt><dd>Public Property Get RunTests() As Integer</dd>
<dt>Description:</dt><dd>Gets the number of run tests.</dd>
</dl>
<hr />
<h3><a name="Failures">Failures</a></h3>
<dl>
<dt>Definition:</dt><dd>Public Property Get Failures() As TestErrors</dd>
<dt>Description:</dt><dd>Returns a collection of failures</dd>
</dl>
<hr />
<h3><a name="Errors">Errors</a></h3>
<dl>
<dt>Definition:</dt><dd>Public Property Get Errors() As TestErrors</dd>
<dt>Description:</dt><dd>Returns a collection of errors</dd>
</dl>
<hr />
<h3><a name="Parameters">Parameters</a></h3>
<dl>
<dt>Definition:</dt>
<dd>Public Property Get Parameters() As TestParameters</dd>
<dd>Public Property Set Parameters(colParameters As TestParameters)</dd>
<dt>Description:</dt><dd>Gets/Sets the parameter collection to be used by the test cases</dd>
</dl>
<hr />
<h3><a name="Assert">Assert</a></h3>
<dl>
<dt>Definition:</dt><dd>Public Sub Assert(bCondition As Boolean, Optional sMessage As String)</dd>
<dt>Description:</dt>
<dd>Asserts that a condition is true. If it isn't it raises a failure with the given message.<br />
bCondition: condition to be asserted<br />
sMessage: optional message describing the asserted condition</dd>
</dl>
<hr />
<h3><a name="AssertEqualsString">AssertEqualsString</a></h3>
<dl>
<dt>Definition:</dt><dd>Public Sub AssertEqualsString(sExpected As String, sActual As String, Optional sMessage As String)</dd>
<dt>Description:</dt>
<dd>Asserts that the expected string equals the actual string.<br />
sExpected: the expected value<br />
sActual: the actual value<br />
sMessage: optional message describing the asserted condition</dd>
</dl>
<hr />
<h3><a name="AssertEqualsLong">AssertEqualsLong</a></h3>
<dl>
<dt>Definition:</dt><dd>Public Sub AssertEqualsLong(lExpected As Long, lActual As Long, Optional sMessage As String)</dd>
<dt>Description:</dt><dd>
Asserts that the expected long value equals the actual long value.<br />
lExpected: the expected value<br />
lActual: the actual value<br />
sMessage: optional message describing the asserted condition</dd>
</dl>
<hr />
<h3><a name="AssertEqualsDouble">AssertEqualsDouble</a></h3>
<dl>
<dt>Definition:</dt><dd>Public Sub AssertEqualsDouble(dExpected As Double, dActual As Double, dDelta As Double, Optional sMessage As String)</dd>
<dt>Description:</dt><dd>
Asserts that the expected double value equals the actual double value with delta precision.<br />
dExpected: the expected value<br />
dActual: the actual value<br />
dDelta: tolerated precision<br />
sMessage: optional message describing the asserted condition</dd>
</dl>
<hr />
<h3><a name="AssertEqualsVariant">AssertEqualsVariant</a></h3>
<dl>
<dt>Definition:</dt><dd>Public Sub AssertEqualsVariant(vExpected As Variant, vActual As Variant, Optional sMessage As String)</dd>
<dt>Description:</dt><dd>
Asserts that the expected variant equals the actual variant.<br />
vExpected: the expected value<br />
vActual: the actual value<br />
sMessage: optional message describing the asserted condition</dd>
</dl>
<hr />
<h3><a name="AssertExists">AssertExists</a></h3>
<dl>
<dt>Definition:</dt><dd>Public Sub AssertExists(oObject As Object, Optional sMessage As String)</dd>
<dt>Description:</dt><dd>
Asserts that an object is not nothing<br />
oObject: object reference<br />
sMessage: the detail message to record if this assertion fails</dd>
</dl>
<hr />
<h3><a name="AssertEqualsObject">AssertEqualsObject</a></h3>
<dl>
<dt>Definition:</dt><dd>Public Sub AssertEqualsObject(oExpected As Object, oActual As Object, Optional sMessage As String)</dd>
<dt>Description:</dt><dd>
Asserts that the expected object equals the actual object.<br />
oExpected: expected object reference<br />
oActual: actual object reference<br />
sMessage: the detail message to record if this assertion fails</dd>
</dl>
<hr />
<h3><a name="AssertNotEmpty">AssertNotEmpty</a></h3>
<dl>
<dt>Definition:</dt><dd>Public Sub AssertNotEmpty(vVariant As Variant, Optional sMessage As String)</dd>
<dt>Description:</dt><dd>
Asserts that a variant is not empty<br />
vVariant: variant to evaluate<br />
sMessage: the detail message to record if this assertion fails</dd>
</dl>
<hr />
<h3><a name="AssertNotNull">AssertNotNull</a></h3>
<dl>
<dt>Definition:</dt><dd>Public Sub AssertNotNull(vVariant As Variant, Optional sMessage As String)</dd>
<dt>Description:</dt><dd>
Asserts that a variant is not null<br />
vVariant: variant to evaluate<br />
sMessage: the detail message to record if this assertion fails</dd>
</dl>
<hr />
<h3><a name="AssertEqualsError">AssertEqualsError</a></h3>
<dl>
<dt>Definition:</dt><dd>Public Sub AssertEqualsError(oError As ErrObject, Optional lError As Long, Optional sMessage As String)</dd>
<dt>Description:</dt><dd>
Asserts that an error was thrown<br />
lError: error number to compare</dd>
</dl>
<h2>Events:</h2>
<h3><a name="AfterStartTest">AfterStartTest</a></h3>
<dl>
<dt>Definition:</dt><dd>Public Event AfterStartTest(oTestCase As ITestCase)</dd>
<dt>Description:</dt><dd>Event is raised after the specified test case has started executing.</dd>
</dl>
<hr />
<h3><a name="AfterEndTest">AfterEndTest</a></h3>
<dl>
<dt>Definition:</dt><dd>Public Event AfterEndTest()</dd>
<dt>Description:</dt><dd>Event is raised after the specified test case has finished executing.</dd>
</dl>
<hr />
<h3><a name="AfterAddError">AfterAddError</a></h3>
<dl>
<dt>Definition:</dt><dd>Public Event AfterAddError(oError As TestError)</dd>
<dt>Description:</dt><dd>Event is raised when an error has occurred.</dd>
</dl>
<hr />
<h3><a name="AfterAddFailure">AfterAddFailure</a></h3>
<dl>
<dt>Definition:</dt><dd>Public Event AfterAddFailure(oError As TestError)</dd>
<dt>Description:</dt><dd>Event is raised when a failure has been generated.</dd>
</dl>
<hr />
<h3><a name="AfterAddTrace">AfterAddTrace</a></h3>
<dl>
<dt>Definition:</dt><dd>Public Event AfterAddTrace(sMessage As String)</dd>
<dt>Description:</dt><dd>Event is raised after the new trace message has been logged.</dd>
</dl>
</body>
</html>