e6e9b4b1b0
[GB.TEST] * NEW: TapParser can now parse subtests. Consequently, TestRunner assembles a tree of TestAssertions. * BUG: Remove trailing '\r' characters from TapStream lines. By our convention a subtest is opened by a "Test ..." line and closed by its summarizing "ok" / "not ok" assertion. This commit regresses on TInternals's reflection tests because I added tests for the parser and runner which need event handlers to do their testing. These are unintentionally detected as test methods.
94 lines
2.7 KiB
Text
94 lines
2.7 KiB
Text
' Gambas test file
|
|
|
|
'' TODO: Test parsing of SkipAll plans
|
|
Public Sub SkipAll()
|
|
Test.SkipAll("Not yet implemented")
|
|
End
|
|
|
|
Private $aSubtestEvents As New String[]
|
|
|
|
'' Test the order of events from the parser.
|
|
Public Sub Subtests()
|
|
Dim sTAP As String = ""
|
|
"# This tests subtest parsing and order of events\n"
|
|
"This line is ignored.\n"
|
|
"Test Subtest\n"
|
|
" ok 1 - good\n"
|
|
" ok 2 - better\n"
|
|
" not ok 3 - acceptable # TODO this was expected\n"
|
|
" 1..3\n"
|
|
"ok 1 - Subtest\n"
|
|
"\n"
|
|
"Test Another\n"
|
|
" 1..1\n"
|
|
" not ok 1 - failed\n"
|
|
"not ok 2 - Another\n"
|
|
Dim hTAP As Stream
|
|
Dim hParser As New TapParser As "SubtestsParser"
|
|
|
|
hTAP = Open String sTAP For Read
|
|
hParser.Parse(hTAP)
|
|
|
|
Test.Plan(15 + 1)
|
|
Assert.Equals($aSubtestEvents.Count, 15, "Event count is correct")
|
|
Assert.Equals($aSubtestEvents[00], "Diag")
|
|
Assert.Equals($aSubtestEvents[01], "Else")
|
|
Assert.Equals($aSubtestEvents[02], "Begin")
|
|
Assert.Equals($aSubtestEvents[03], "Ok")
|
|
Assert.Equals($aSubtestEvents[04], "Ok")
|
|
Assert.Equals($aSubtestEvents[05], "NotOk")
|
|
Assert.Equals($aSubtestEvents[06], "Plan")
|
|
Assert.Equals($aSubtestEvents[07], "End")
|
|
Assert.Equals($aSubtestEvents[08], "Ok")
|
|
Assert.Equals($aSubtestEvents[09], "Else")
|
|
Assert.Equals($aSubtestEvents[10], "Begin")
|
|
Assert.Equals($aSubtestEvents[11], "Plan")
|
|
Assert.Equals($aSubtestEvents[12], "NotOk")
|
|
Assert.Equals($aSubtestEvents[13], "End")
|
|
Assert.Equals($aSubtestEvents[14], "NotOk")
|
|
|
|
Close #hTAP
|
|
End
|
|
|
|
Public Sub SubtestsParser_Plan((Start) As Integer, (End) As Integer)
|
|
$aSubtestEvents.Push("Plan")
|
|
End
|
|
|
|
Public Sub SubtestsParser_Assert((Ok) As Boolean, (Id) As Long, (Description) As String, (Directive) As Integer, (Comment) As String)
|
|
$aSubtestEvents.Push(IIf(Ok, "Ok", "NotOk"))
|
|
End
|
|
|
|
Public Sub SubtestsParser_Diagnostic((Comment) As String)
|
|
$aSubtestEvents.Push("Diag")
|
|
End
|
|
|
|
Public Sub SubtestsParser_Else((Line) As String)
|
|
$aSubtestEvents.Push("Else")
|
|
End
|
|
|
|
Public Sub SubtestsParser_BeginSubtest((Description) As String)
|
|
$aSubtestEvents.Push("Begin")
|
|
End
|
|
|
|
Public Sub SubtestsParser_EndSubtest()
|
|
$aSubtestEvents.Push("End")
|
|
End
|
|
|
|
'' Examine the object hierarchy returned by TestRunner, by running the Subtests test externally.
|
|
Public Sub Runner()
|
|
|
|
Dim hStats As TestStats = TestRunner.Run(Application.Path, "TParser.Subtests")
|
|
|
|
Test.Plan(7)
|
|
|
|
Assert.NotNull(hStats, "Stats object is not null")
|
|
Assert.Equals(hStats.Planned, 1)
|
|
Assert.Equals(hStats.Passed, 1)
|
|
|
|
Dim hMethod As TestAssertion = hStats.Subtests[0]
|
|
Assert.Ok(hMethod.Success)
|
|
Assert.Equals(hMethod.Subtests.Count, 16)
|
|
Assert.Equals(hMethod.Subtests[0].Description, "- Event count is correct")
|
|
Assert.Equals(hMethod.Subtests[0].Subtests.Count, 0)
|
|
|
|
End
|