Class TestResult

Description:

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.

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.

Interface Implementation:

Known Subclasses:

Method Summary:

Method:Definition:
Assert Public Sub Assert(bCondition As Boolean, Optional sMessage As String)
AssertEqualsDouble Public Sub AssertEqualsDouble(dExpected As Double, dActual As Double, dDelta As Double, Optional sMessage As String)
AssertEqualsError Public Sub AssertEqualsError(oError As ErrObject, Optional lError As Long, Optional sMessage As String)
AssertEqualsLong Public Sub AssertEqualsLong(lExpected As Long, lActual As Long, Optional sMessage As String)
AssertEqualsObject Public Sub AssertEqualsObject(oExpected As Object, oActual As Object, Optional sMessage As String)
AssertEqualsString Public Sub AssertEqualsString(sExpected As String, sActual As String, Optional sMessage As String)
AssertEqualsVariant Public Sub AssertEqualsVariant(vExpected As Variant, vActual As Variant, Optional sMessage As String)
AssertExists Public Sub AssertExists(oObject As Object, Optional sMessage As String)
AssertNotEmpty Public Sub AssertNotEmpty(vVariant As Variant, Optional sMessage As String)
AssertNotNull Public Sub AssertNotNull(vVariant As Variant, Optional sMessage As String)
AddError Public Sub AddError(lNumber As Long, sSource As String, sDescription As String)
AddFailure Public Sub AddFailure(sDescription As String)
AddTrace Public Sub AddTrace(sMessage As String)
EndTest Public Sub EndTest()
Errors Public Property Get Errors() As TestErrors
Failures Public Property Get Failures() As TestErrors
Parameters Public Property Get Parameters() As TestParameters
Public Property Set Parameters(colParameters As TestParameters)
Run Public Sub Run(ByRef oTestResult As TestResult)
RunTests Public Property Get RunTests() As Integer
StartTest Public Sub StartTest(oTestCase As ITestCase)
WasSuccessful Public Property Get WasSuccessful() As Boolean

Event Summary:

Event:Definition:
AfterStartTest Public Event AfterStartTest(oTestCase As ITestCase)
AfterEndTest Public Event AfterEndTest()
AfterAddError Public Event AfterAddError(oError As TestError)
AfterAddFailure Public Event AfterAddFailure(oError As TestError)
AfterAddTrace Public Event AfterAddTrace(sMessage As String)

Methods:

WasSuccessful

Definition:
Public Property Get WasSuccessful() As Boolean
Description:
Returns whether the entire test was successful or not.

StartTest

Definition:
Public Sub StartTest(oTestCase As ITestCase)
Description:
Informs the result that a test will be started.

EndTest

Definition:
Public Sub EndTest()
Description:
Informs the result that a test is completed.

AddFailure

Definition:
Public Sub AddFailure(sDescription As String)
Description:
Adds a failure to the collection of failures.

AddError

Definition:
Public Sub AddError(lNumber As Long, sSource As String, sDescription As String)
Description:
Adds a error to the collection of errors.

AddTrace

Definition:
Public Sub AddTrace(sMessage As String)
Description:
Add trace message

RunTests

Definition:
Public Property Get RunTests() As Integer
Description:
Gets the number of run tests.

Failures

Definition:
Public Property Get Failures() As TestErrors
Description:
Returns a collection of failures

Errors

Definition:
Public Property Get Errors() As TestErrors
Description:
Returns a collection of errors

Parameters

Definition:
Public Property Get Parameters() As TestParameters
Public Property Set Parameters(colParameters As TestParameters)
Description:
Gets/Sets the parameter collection to be used by the test cases

Assert

Definition:
Public Sub Assert(bCondition As Boolean, Optional sMessage As String)
Description:
Asserts that a condition is true. If it isn't it raises a failure with the given message.
bCondition: condition to be asserted
sMessage: optional message describing the asserted condition

AssertEqualsString

Definition:
Public Sub AssertEqualsString(sExpected As String, sActual As String, Optional sMessage As String)
Description:
Asserts that the expected string equals the actual string.
sExpected: the expected value
sActual: the actual value
sMessage: optional message describing the asserted condition

AssertEqualsLong

Definition:
Public Sub AssertEqualsLong(lExpected As Long, lActual As Long, Optional sMessage As String)
Description:
Asserts that the expected long value equals the actual long value.
lExpected: the expected value
lActual: the actual value
sMessage: optional message describing the asserted condition

AssertEqualsDouble

Definition:
Public Sub AssertEqualsDouble(dExpected As Double, dActual As Double, dDelta As Double, Optional sMessage As String)
Description:
Asserts that the expected double value equals the actual double value with delta precision.
dExpected: the expected value
dActual: the actual value
dDelta: tolerated precision
sMessage: optional message describing the asserted condition

AssertEqualsVariant

Definition:
Public Sub AssertEqualsVariant(vExpected As Variant, vActual As Variant, Optional sMessage As String)
Description:
Asserts that the expected variant equals the actual variant.
vExpected: the expected value
vActual: the actual value
sMessage: optional message describing the asserted condition

AssertExists

Definition:
Public Sub AssertExists(oObject As Object, Optional sMessage As String)
Description:
Asserts that an object is not nothing
oObject: object reference
sMessage: the detail message to record if this assertion fails

AssertEqualsObject

Definition:
Public Sub AssertEqualsObject(oExpected As Object, oActual As Object, Optional sMessage As String)
Description:
Asserts that the expected object equals the actual object.
oExpected: expected object reference
oActual: actual object reference
sMessage: the detail message to record if this assertion fails

AssertNotEmpty

Definition:
Public Sub AssertNotEmpty(vVariant As Variant, Optional sMessage As String)
Description:
Asserts that a variant is not empty
vVariant: variant to evaluate
sMessage: the detail message to record if this assertion fails

AssertNotNull

Definition:
Public Sub AssertNotNull(vVariant As Variant, Optional sMessage As String)
Description:
Asserts that a variant is not null
vVariant: variant to evaluate
sMessage: the detail message to record if this assertion fails

AssertEqualsError

Definition:
Public Sub AssertEqualsError(oError As ErrObject, Optional lError As Long, Optional sMessage As String)
Description:
Asserts that an error was thrown
lError: error number to compare

Events:

AfterStartTest

Definition:
Public Event AfterStartTest(oTestCase As ITestCase)
Description:
Event is raised after the specified test case has started executing.

AfterEndTest

Definition:
Public Event AfterEndTest()
Description:
Event is raised after the specified test case has finished executing.

AfterAddError

Definition:
Public Event AfterAddError(oError As TestError)
Description:
Event is raised when an error has occurred.

AfterAddFailure

Definition:
Public Event AfterAddFailure(oError As TestError)
Description:
Event is raised when a failure has been generated.

AfterAddTrace

Definition:
Public Event AfterAddTrace(sMessage As String)
Description:
Event is raised after the new trace message has been logged.