c9c99c0050
[GB.TEST] * NEW: Use gb.test. This removes the Assert and Track classes and uses gb.test.tap instead. Test methods are now executed inside subtests, plan lines are auto- matically emitted by the harness. Differences between gb.tests's and gb.test.tap's Assert module: - Instead of Assert.True and Assert.False, use Assert.Ok. - Instead of Assert.Equals* for every type, there is a generic Assert.Equals for Variants and a specific Assert.StringEquals for strings which prints diagnostics when the test fails. - Assert.BailOut does not terminate the entire program, just the TAP stream. - Assert.ErrorWithCode is called Assert.ErrorCode. All TAP printing is done through Assert now. Errors happening in the test code are not caught and spoofed in the TAP stream anymore, they cause a test failure. The system would be more robust if the testee would be in a different process from the tester.
66 lines
1.5 KiB
Text
66 lines
1.5 KiB
Text
' Gambas class file
|
|
|
|
''' The TestCase class is responsible for executing a specific test case.
|
|
''' The test case to be executed is specified through the Name and TestTestModule
|
|
''' properties in the class. The Run method will call the appropriate Setup
|
|
''' and TearDown methods for the test case as well as executing the test case
|
|
''' method itself.
|
|
|
|
Inherits ITestCase
|
|
|
|
'' Name of the test case
|
|
Property Read Name As String
|
|
|
|
'' Reference to the TestModule containing the test methods to be executed.
|
|
Property Read TestModule As Class
|
|
|
|
Private $Name As String
|
|
Private $MyTestModule As Class
|
|
|
|
'' Initializes the TestCase. Used in lieu of a constructor.
|
|
Public Sub _new(sName As String, TestModule As Class)
|
|
|
|
Assert sName <> Null
|
|
$Name = sName
|
|
Assert TestModule
|
|
$MyTestModule = TestModule
|
|
|
|
End Sub
|
|
|
|
'' Name of the test case
|
|
Function Name_Read() As String
|
|
|
|
Assert $Name <> Null
|
|
Return $Name
|
|
|
|
End
|
|
|
|
'Create the fixture, run the test and collect the results in Track
|
|
Public Sub Run()
|
|
|
|
Assert $MyTestModule
|
|
|
|
'$MyTestModule.SetupEach
|
|
If $MyTestModule.Symbols.Exist("SetupEach") Then
|
|
Object.Call($MyTestModule, "SetupEach")
|
|
Endif
|
|
|
|
Object.Call($MyTestModule, Me.name)
|
|
|
|
If $MyTestModule.Symbols.Exist("TeardownEach") Then
|
|
Object.Call($MyTestModule, "TeardownEach")
|
|
Endif
|
|
|
|
Catch
|
|
|
|
Debug "Unittest stopped with error \"" & Error.Text & "\" caused by " & $MyTestModule.Name & "." & Me.Name & "."
|
|
' Quit
|
|
|
|
End Sub
|
|
|
|
Private Function TestModule_Read() As Class
|
|
|
|
Assert $MyTestModule
|
|
Return $MyTestModule
|
|
|
|
End
|