155 lines
2.8 KiB
Text
155 lines
2.8 KiB
Text
' Gambas class file
|
|
|
|
Export
|
|
|
|
' This interface identifies TestContainer classes. TestContainers are a
|
|
' classes that hold different test case methods.
|
|
|
|
Property Read Name As String
|
|
|
|
' Return the name of the different test case methods in this test container
|
|
Property CaseNames As String[]
|
|
Private $CaseNames As String[]
|
|
|
|
Property Case As ITestCase
|
|
Property Result As TestResult
|
|
|
|
Private $Case As ITestCase
|
|
Private $Result As TestResult
|
|
Property Debug As Boolean
|
|
|
|
Private $Debug As Boolean
|
|
|
|
Public Sub _new(Optional ShowDebug As Boolean)
|
|
|
|
Dim symbols As String[]
|
|
Dim symbol As String
|
|
|
|
$Debug = ShowDebug
|
|
|
|
' ------------------------------------------------- Fill Cases by listing all Testmethods
|
|
$CaseNames = New String[]
|
|
symbols = Object.Class(Me).Symbols
|
|
|
|
For Each symbol In symbols
|
|
If Left(symbol, 4) = "Test" Then
|
|
$CaseNames.Add(symbol)
|
|
Endif
|
|
Next
|
|
|
|
End
|
|
|
|
' Run the specified test case methods in this test container
|
|
Public Sub RunCase(oCase As ITestCase, oTestResult As TestResult)
|
|
|
|
Dim MethodName As String
|
|
Dim hClass As Class
|
|
|
|
Me.Case = oCase
|
|
Me.Result = oTestResult
|
|
|
|
' ------------------------------------------------- Iterate through test methods
|
|
hClass = Object.Class(Me)
|
|
For Each MethodName In $CaseNames
|
|
If hClass[MethodName].Kind = Class.Method Then
|
|
If MethodName = Me.Case.Name Then
|
|
If Me.Debug Then
|
|
Debug "Call";; MethodName
|
|
Endif
|
|
Object.Call(Me, MethodName)
|
|
Endif
|
|
Endif
|
|
Next
|
|
|
|
End Sub
|
|
|
|
'Initialize the test fixture
|
|
Public Sub SetupEach()
|
|
|
|
If Me.Debug Then
|
|
Debug "Setup single Test"
|
|
Endif
|
|
|
|
End Sub
|
|
|
|
'Destroy the test fixture
|
|
Public Sub TearDownEach()
|
|
|
|
If Me.Debug Then
|
|
Debug "Teardown single Test"
|
|
Endif
|
|
|
|
End Sub
|
|
|
|
'Initialize the test fixture for container
|
|
Public Sub SetupContainer()
|
|
|
|
If Me.Debug Then
|
|
Debug "Setup Container " & Object.Class(Me).Name
|
|
Endif
|
|
|
|
End Sub
|
|
|
|
'Destroy the test fixture for container
|
|
Public Sub TearDownContainer()
|
|
|
|
If Me.Debug Then
|
|
Debug "Teardown Container " & Object.Class(Me).Name
|
|
Endif
|
|
|
|
End Sub
|
|
|
|
Private Function CaseNames_Read() As String[]
|
|
|
|
Return $CaseNames
|
|
|
|
End
|
|
|
|
Private Sub CaseNames_Write(Value As String[])
|
|
|
|
$CaseNames = value
|
|
|
|
End
|
|
|
|
Private Function Case_Read() As ITestCase
|
|
|
|
Return $Case
|
|
|
|
End
|
|
|
|
Private Sub Case_Write(Value As ITestCase)
|
|
|
|
$Case = Value
|
|
|
|
End
|
|
|
|
Private Function Result_Read() As TestResult
|
|
|
|
Return $Result
|
|
|
|
End
|
|
|
|
Private Sub Result_Write(Value As TestResult)
|
|
|
|
$Result = Value
|
|
|
|
End
|
|
|
|
'' Returns the classname of the TestContainer
|
|
Private Function Name_Read() As String
|
|
|
|
Return Object.Class(Me).Name
|
|
|
|
End
|
|
|
|
Private Function Debug_Read() As Boolean
|
|
|
|
Return $Debug
|
|
|
|
End
|
|
|
|
Private Sub Debug_Write(Value As Boolean)
|
|
|
|
$Debug = Value
|
|
|
|
End
|