gb.test and gbt3 some refactoring and future tasks
This commit is contained in:
parent
aeef68eedf
commit
8ff76cb279
7 changed files with 61 additions and 37 deletions
|
@ -1,7 +1,7 @@
|
|||
# Gambas Project File 3.0
|
||||
Title=Gambas Project Tester
|
||||
Startup=Main
|
||||
Version=0.0.25
|
||||
Version=0.0.26
|
||||
Component=gb.args
|
||||
Component=gb.test
|
||||
Description="Test a Gambas project from the commandline. The project has to use the component gb.test and contain testmodule(s)."
|
||||
|
|
|
@ -34,7 +34,7 @@ Public Sub Main()
|
|||
Error.Raise("Error: Path to project not found.")
|
||||
Endif
|
||||
|
||||
'Chossen Tests
|
||||
'Choosen Tests
|
||||
If sTests Then
|
||||
sTestCmd = "\"" & sTests & "" "\""
|
||||
Else
|
||||
|
@ -67,6 +67,7 @@ Public Sub Main()
|
|||
$hHarness.Read(hTestee, File.Name(sPath))
|
||||
|
||||
PrintSummary()
|
||||
ReturnExitCode()
|
||||
|
||||
' ------------------------------------------------- Restore project
|
||||
|
||||
|
@ -81,6 +82,12 @@ Catch
|
|||
|
||||
End
|
||||
|
||||
Private Sub ReturnExitCode()
|
||||
|
||||
'FIXME: has to be done
|
||||
|
||||
End
|
||||
|
||||
Private Sub PrintSummary()
|
||||
|
||||
'FIXME: As gb.test is able to print a summary, that should be used only
|
||||
|
|
14
comp/src/gb.test/.hidden/summary-example.txt
Normal file
14
comp/src/gb.test/.hidden/summary-example.txt
Normal file
|
@ -0,0 +1,14 @@
|
|||
#
|
||||
# --------------- Fail ---------------
|
||||
# 1000 Tests, 998 ok
|
||||
#
|
||||
# 2 Tests failed:
|
||||
# 996: TestWurst:StretchWurst
|
||||
# 998: TestSuppe:ThrowSuppe
|
||||
#
|
||||
# 1 Tests skipped:
|
||||
# 100: TestKaese:LoecherSchneiden
|
||||
#
|
||||
# 1 Test Todo:
|
||||
# 1000: TestBier:Trinken
|
||||
#
|
|
@ -21,7 +21,6 @@ End
|
|||
Public Sub Reset()
|
||||
$hPrinter = New TapPrinter As "Printer"
|
||||
End
|
||||
|
||||
Public Sub IntendedFailure()
|
||||
$bIntendedFailure = True
|
||||
End
|
||||
|
@ -71,11 +70,11 @@ End
|
|||
Public Sub BailOut(Optional Comment As String)
|
||||
$hPrinter.BailOut(Comment)
|
||||
End
|
||||
|
||||
'' Synonym for Note
|
||||
Public Sub Diagnostic(Comment As String)
|
||||
$hPrinter.Diagnostic(Comment)
|
||||
End
|
||||
|
||||
'' Synonym for Diagnostic
|
||||
Public Sub Note(Comment As String)
|
||||
$hPrinter.Note(Comment)
|
||||
End
|
||||
|
|
|
@ -4,18 +4,20 @@ Public Sub Main()
|
|||
|
||||
Dim Tests As String
|
||||
|
||||
' These must succeed:
|
||||
' ------------------------------------------------- These must succeed
|
||||
Tests = "TestAllAsserts, TestElse, TestError, TestSetupTeardown, TestInternals, TestFailures"
|
||||
|
||||
' ------------------------------------------------- This must not succeed
|
||||
'Tests = "TestCrashes"
|
||||
|
||||
' ------------------------------------------------- This must bailout
|
||||
'Tests = "TestBailout"
|
||||
|
||||
' ------------------------------------------------- Playing field
|
||||
|
||||
Tests = "TestAllAsserts"
|
||||
|
||||
'Tests = "TestAllAsserts"
|
||||
Tests = "TestSummary"
|
||||
|
||||
'This must not succeed
|
||||
'Tests = "TestCrashes"
|
||||
|
||||
'This must bailout
|
||||
'Tests = "TestBailout"
|
||||
|
||||
'FIXME:
|
||||
'This failes, but should not
|
||||
|
|
|
@ -20,8 +20,14 @@ End
|
|||
|
||||
Private Sub PrintSummary()
|
||||
|
||||
With Assert.Session
|
||||
Assert.Note(Subst$(("Test run '&1' &2"), .Summary.Description, IIf(.Summary.Success, "PASSED", "FAILED")))
|
||||
'needed for debugging, to doubleclick on it
|
||||
Dim Session As TapContext
|
||||
|
||||
Session = Assert.Session
|
||||
With Session
|
||||
'Proposal: Typo, PASSED/FAILED is the important, so start with it
|
||||
'Assert.Note(Subst$(("Test run '&1' &2"), .Summary.Description, IIf(.Summary.Success, "PASSED", "FAILED")))
|
||||
Assert.Note(Subst$(("&2 - ran: '&1' "), .Summary.Description, IIf(.Summary.Success, "PASSED", "FAILED")))
|
||||
If .TestsRun <> .Plan Then Assert.Note(Subst$(("Planned &1 tests but ran &2"), .Plan, .TestsRun))
|
||||
If Not .Summary.Success Then ShowFailures(.Summary.Subtests, "")
|
||||
End With
|
||||
|
@ -42,7 +48,6 @@ Private Sub ShowFailures(Tests As TestAssertion[], Prefix As String)
|
|||
|
||||
End
|
||||
|
||||
'
|
||||
'' Run all tests, optional limited by Container or TestCaseName. Track contains .
|
||||
|
||||
Private Function RunTests(Tests As String)
|
||||
|
@ -54,9 +59,6 @@ Private Function RunTests(Tests As String)
|
|||
|
||||
aTestCommands = TestCommand.ParseCommands(Tests)
|
||||
|
||||
'FIXME: SingleTestModule, NameProcedure do not exist any more, they are replaced by aTestCommands
|
||||
Dim NameProcedure, SingleTestModule As String
|
||||
|
||||
For Each sTestModule In GetAllTestModules(aTestCommands)
|
||||
TestModule = Class.Load(sTestModule)
|
||||
Suite.AddAllTestCases(TestModule, aTestCommands)
|
||||
|
@ -68,8 +70,6 @@ Private Function RunTests(Tests As String)
|
|||
|
||||
End
|
||||
|
||||
''
|
||||
|
||||
Function GetAllTestModules(Commands As TestCommand[]) As String[]
|
||||
|
||||
Dim TestClass As Class
|
||||
|
@ -85,35 +85,26 @@ Function GetAllTestModules(Commands As TestCommand[]) As String[]
|
|||
Assert sNames
|
||||
|
||||
sNames.Sort
|
||||
|
||||
For Each sName In sNames
|
||||
TestClass = Class.Load(sName)
|
||||
If Not TestClass Then Error.Raise(Subst$(("Could not load test module '&1'"), sName))
|
||||
|
||||
'sName = Class.Stat(sName).Name
|
||||
|
||||
'Atention: Class.Stat(sName).Name does not work if included as component
|
||||
'Then this creates the error:
|
||||
'Bail out! Error in Test->GetAllTestModuleNames: Unknown symbol 'Stat' in class 'Class'
|
||||
|
||||
If TestModuleNames.Exist(sName) Then Continue
|
||||
If Commands.Count = 0 Then
|
||||
'Add every Testmodule
|
||||
TestModuleNames.Add(sName)
|
||||
Else
|
||||
' Add only testmodules whose names exist in Commands
|
||||
'Add only testmodules whose names exist in Commands
|
||||
For Each Command In Commands
|
||||
If Lower(Command.ModuleName) = Lower(sName) Then
|
||||
TestModuleNames.Add(sName)
|
||||
Endif
|
||||
Next
|
||||
' If Lower(sName) = Lower(SingleTestModule) Then
|
||||
' TestModuleNames.Add(sName)
|
||||
' Endif
|
||||
Endif
|
||||
Next
|
||||
|
||||
TestModuleNames.Sort
|
||||
' Print "# These TestContainer will be executed:\n#\n# " & TestModuleNames.Join("\n# ") & "\n"
|
||||
|
||||
Return TestModuleNames
|
||||
|
||||
Catch
|
||||
|
|
|
@ -1,12 +1,23 @@
|
|||
## To Do
|
||||
|
||||
- Subtests don't count the right way
|
||||
> If there is only one testmodule called, subtest counts a lot of subtests instead just one
|
||||
- Summary as a TAP comment
|
||||
- Test.Main has to complain if testmodule doesn't exist
|
||||
- Test.Main options
|
||||
> Test.Main needs a couple of options
|
||||
* [ ] Sparse to switch off TAP output of subtests
|
||||
* [ ] NoSummary to switch off summary
|
||||
* [ ] Silent to switch off TAP output to console
|
||||
- Ensure TAP created according to spec
|
||||
- Install gbt3 at Gambas installation
|
||||
- gbt3 has to return exit status at the end
|
||||
- Assert documentation
|
||||
|
||||
## Work
|
||||
|
||||
- gb.test doesn't print to console
|
||||
- Summary as a TAP comment
|
||||
> Description in .hidden/summary-example-txt
|
||||
|
||||
## Done
|
||||
|
||||
- Subtests don't count the right way
|
||||
> If there is only one testmodule called, subtest counts a lot of subtests instead just one
|
||||
- gb.test doesn't print to console
|
||||
|
|
Loading…
Reference in a new issue