106 lines
2.4 KiB
Text
106 lines
2.4 KiB
Text
' Gambas module file
|
|
|
|
Export
|
|
|
|
Public Sub Main()
|
|
|
|
Dim res As New TestResult
|
|
|
|
'RunTests(res, "GuTestIntentionalError", Null, False)
|
|
RunTests(res, Null, Null, False)
|
|
PrintResult(res)
|
|
|
|
End
|
|
|
|
'' Show the Test Runner Form
|
|
Public Sub ShowTestRunnerForm()
|
|
|
|
Dim fm As New FmRunner
|
|
|
|
fm.Show()
|
|
|
|
End
|
|
|
|
Public Sub PrintResult(Res As TestResult)
|
|
|
|
Dim Errs As TestErrors
|
|
Dim Fails As TestErrors
|
|
Dim Err As TestError
|
|
Dim Fail As TestError
|
|
' Dim C As Class
|
|
|
|
'TS.Run(Res)
|
|
Errs = Res.Errors
|
|
Fails = Res.Failures
|
|
|
|
Print "----------------------- Test Results ----------------------- "
|
|
Print res.CountRunnedTests & " Test done"
|
|
Print "------------------------------------------------------------ "
|
|
If Errs.Count > 0 Then
|
|
For Each Err In Errs.Items
|
|
Print "Error in:";; Err.Source
|
|
Print "Error:";; Err.Description
|
|
Next
|
|
Else
|
|
Print "No Errors"
|
|
Endif
|
|
|
|
If Fails.Count > 0 Then
|
|
For Each Fail In Fails.Items
|
|
Print "Failure in:";; Fail.Source
|
|
Print "Failure:";; Fail.Description
|
|
Next
|
|
Else
|
|
Print "No Failures"
|
|
Endif
|
|
Print "------------------------- Test End -------------------------"
|
|
If res.WasSuccessful = True Then
|
|
Print "Success!"
|
|
Else
|
|
Print "Not successful"
|
|
Endif
|
|
|
|
End
|
|
|
|
'' Run all tests, optional limited by Container or TestCaseName. TestResult contains .
|
|
|
|
Public Sub RunTests(Result As TestResult, Optional ContainerName As String, Optional CaseName As String, Optional ShowDebug As Boolean)
|
|
|
|
Dim Container As TestContainer
|
|
Dim Suite As New TestSuite
|
|
|
|
If ContainerName = Null Then
|
|
If CaseName = Null Then
|
|
For Each ContainerName In MRunner.GetAllTestContainerNames()
|
|
Container = Object.New(ContainerName)
|
|
Suite.AddAllTestCases(Container)
|
|
Next
|
|
Endif
|
|
Else
|
|
Container = Object.New(ContainerName)
|
|
If CaseName = Null Then
|
|
Suite.AddAllTestCases(Container)
|
|
Else
|
|
Suite.AddNewTestCase(CaseName, Container)
|
|
Endif
|
|
Endif
|
|
|
|
Suite.Run(Result, ShowDebug)
|
|
|
|
End
|
|
|
|
Public Function GetAllTestContainerNames() As String[]
|
|
|
|
Dim ret As New String[]
|
|
Dim C As Class
|
|
|
|
For Each C In Classes
|
|
If Left(C.Name, 6) = "GuTest" Then
|
|
ret.add(C.Name)
|
|
Endif
|
|
Next
|
|
ret.Sort()
|
|
|
|
Return ret
|
|
|
|
End
|