#__Test


Load
M
Class
(Class)s
#Assert

C
'This module extends the Assert instruction, which checks
'that Expression is TRUE, and if the Expression is FALSE,
'an uncatchable "Assertion failed" error is raised, the
'PRINT or ERROR instruction is executed, and the program stops immediately.
_IntendedFailure
V
b

Ok
M
b
(Result)b[(Description)s]
'Assert that Result = True
Pass
M
b
[(Description)s]
'Assert that a test is passed. Reports Ok
Fail
M
b
[(Description)s]
'Assert fail. Reports not ok.
NotOk
M
b
(Result)b[(Description)s]
'Assert that Result = False.
Equals
M
b
(Got)v(Expected)v[(Description)s]
'Assert that Got = Expected
Notequals
M
b
(Got)v(UnExpected)v[(Description)s]
'Assert that Got <> Expected
LessEqual
M
b
(Got)v(Bound)v[(Description)s]
'Assert that Got <= Bound
Less
M
b
(Got)v(Bound)v[(Description)s]
'Assert that Got < Bound
GreaterEqual
M
b
(Got)v(Bound)v[(Description)s]
'Assert that Got >= Bound
Greater
M
b
(Got)v(Bound)v[(Description)s]
'Assert that Got > Bound
Approximate
M
b
(Got)f(Expected)f(Precision)f[(Description)s]
'Asserts that _Got_ has an [absolute error](https://en.wikipedia.org/wiki/Approximation_error) to _Expected_ of at most _Precision_.
RelativeApproximate
M
b
(Got)f(Expected)f(RelPrecision)f[(Description)s]
'Asserts that _Got_ has a [relative error](https://en.wikipedia.org/wiki/Approximation_error) to _Expected_ of at most _RelPrecision_.
'_Expected_ may not be zero, unless _Got_ is also zero in which case the test succeeds.
IsType
M
b
(Got)v(Type)i[(Description)s]
'Assert that Got is of the type Type
Null
M
b
(Got)v[(Description)s]
'Assert that Got = Null
NotNull
M
b
(Got)v[(Description)s]
'Assert that Got <> Null
Like
M
b
(Got)s(Pattern)s[(Description)s]
'Assert that Got Like Pattern. See also the Like string operator.
Match
M
b
(Got)s(Pattern)s[(Description)s]
'Assert that Got Match Pattern. See also the Match string operator.
StringEquals
M
b
(Got)s(Expected)s[(Description)s]
'Assert that Got = Expected. On failure reports hints about the difference.
Error
M
b
[(Description)s]
'Assert that an error happened. Reports not ok if no error happened.
'
'Example:
'Try 2/0
'Assert.Error("division by zero")
ErrorCode
M
b
(Code)i[(Description)s]
'Assert that an error happened with error code. Reports not ok
'if no error happend or if the error code is wrong.
'
'Example:
'Try Print 2 / 0
'Assert.ErrorCode(26, "division by zero with code 26")
Noterror
M
b
[(Description)s]
'Assert that no error happened.
'
'
#Test

C
'The class Test is the central class which orchestrates
'the execution of tests and also gives a couple of tools to
'manipulate running tests.
NO_PLAN
C
i
-1
'Special value for unspecified test plan
_Printer
R
TapPrinter

_Finished
R
b

_Next
P
TestAssertion

_InSetup
V
b

_TRIGGER_GET_ALLTESTS
C
s
"#GetAllTests"
'Used to trigger Test.Main to print all tests as comma separated string.
Main
M

[(Tests)s]
'The static procedure Test.Main() runs tests. By default it runs all tests (aka testmethods) in all
'testmodules of a project ordered by name and prints the result to stdout.
'
'A testmodule is a special class with the ending test. It must contain at minimum one test.
'
'A test is a public sub in a testmodule whose name does not contain an underscore.
'
'On the command line the interpreter is commanded with this line to execute Test.Main():
'
'gbx3 -T "*" /path/to/project
'
'The optional argument ca be used to create a testsuite which chooses any
'combination of testmodule and test(s). The format of the string is like so: Testmodules
'are separated by a comma. If not all tests of a testmodule should be called then the
'name of the testmodule is followed by a dot and a string containing the tests separated
'by a semikolon. For example:
'
'gbx3 -T "testmodule1,testmodule2.test1;test2,testmodule3" /path/to/project
'
'In the Gambas IDE one is able to define testsuites and store them with a individual name
'in a file named ".test" in the project's path.
'
'A test suite stored like that can be called by it's name with a preceeding "@", for example:
'
'gbx3 -T "@My production testsuite1" /path/to/project
'
'Public methods called "_Setup", "_Teardown", "_SetupEach" or "_TeardownEach" inside a testmodule
'can be used to create a testfixture, which defines a special environment for the tests.
AllTests
M
s

'Returns a comma separated string with all tests of the project in the same way Test.Main() wants it.
_Reset
M


BailOut
M

[(Comment)s]
'Prints "Bail out!" to Stdout and stops all testing immediately.
_Print
M

(Line)s
'Prints Line to Stdout
Note
M

(Comment)s
'Synonym for Diagnostic, prints Comment with leading #
Plan
M

(Tests)i[(Comment)s]
'Plan the number of assertions within a test method.
'If the number is not correct, the test fails.
SKIP
M

[(Comment)s]
'Tell the testing system that a test is skipped. Reports ok.
TODO
M

[(Comment)s]
'Tell the testing system that the next assertion is a TODO.
'Even if it fails it reports ok, but will be reported as Todo.
'If the next assertion does not fail, it will be reported as bonus.
_Finish
M


AllTestsCollection
M
Collection

'Returns an collection of all the testmodules and their tests of the project.
'Key is the name of the testmodule, Value is a string array with the names of the tests it contains
Diagnostic
M

(Comment)s
'Synonym for Note, prints Comment with leading #
IntendedFailure
M


'If the next assertion is a failure it reports ok.
'In other words: Reverses the result of the following assertion.
'"not ok" will be "ok" and vice versa.
_Subtest
M

(Description)s[(Tests)i(Comment)s]
SkipAll
M

[(Comment)s]
'Skip the current test.
#TestAssertion

C
'This class represents an "ok" or "not ok" line in TAP.
'It is generated by TapPrinter and TapParser.
NONE
C
i
0
'Possible values for the Directive field
TODO
C
i
1
'Possible values for the Directive field
SKIP
C
i
2
'Possible values for the Directive field
Id
v
l

'The serial number of this test.
Ok
v
b

'Whether "ok" or "not ok" was printed.
Description
v
s

'The test description.
Directive
v
i

'The TAP directive constant NONE, TODO or SKIP.
Comment
v
s

'The comment after the test description and directive, if any.
Subtests
v
TestAssertion[]

'If this is a subtest summary assertion, here are the child assertions.
SubPlanned
v
i

'If this is a subtest summary assertion, its plan line.
SubSkippedAll
v
b

'If this is a subtest summary assertion, whether it was skipped completely.
Line
v
s

'The position in the code where the test was called
Success
r
b

'Whether the test counts as succeeded. A "not ok" test can succeed if it was marked as TODO.
SubSuccess
r
b

'Whether all subtests succeeded.
#TestCommand

CA
'The class TestCommand stores the names of a testmodule and optional tests to be executed.
'It also contains methods to translate testcommands to string and vice versa.
ModuleName
v
s

'Name of the testmodule to be called
Methods
v
String[]

'Name of tests in a testmodule to be called. If empty, all will be called.
_Find
M
TestCommand
(Commands)TestCommand[];(TestModuleName)s
'Finds the Command for the TestModule with name TestModuleName
ToString
M
s
(Commands)TestCommand[];
'Creates a string from an array of testcommands
FromString
M
TestCommand[]
(Tests)s
'Parses a string with comma separated tests and creates an array of TestCommands.
_compare
m
i
(TC)TestCommand;
#TestRunner

C
'Lists tests, Run tests, parse output and collect statistics.
List
M
TestCommand[]
(Project)s
'Returns all tests in a project given by path
Run
M
TestStats
(Project)s[(Tests)s]
'Runs Tests in a project given by path
TapStream_Read
M


TapStream_Error
M

(Message)s
Parser_Version
M

(Version)i
Parser_BeginSubtest
M

(Description)s
Parser_EndSubtest
M


Parser_Plan
M

(Start)i(End)i(SkipAll)b
Parser_Assert
M

(Ok)b(Id)l(Description)s(Directive)i(Comment)s
Parser_BailOut
M

(Comment)s
#TestStats

C
Name
v
s

'Name of the test
ExitCode
v
i

'Exit status of the test process
Success
v
b

'Whether the test was successful (all tests passed and at least one test was executed)
Run
v
i

'Number of run tests
Delta
v
i

'Difference between planned and run tests
BailedOut
v
b

'Whether the test bailed out (aborted gracefully)
BailMessage
v
s

'If BailedOut, this contains the optional attached message
Started
v
d

'When the test started
Ended
v
d

'When the test ended
Version
v
i

'TAP version in use
Planned
v
i

'Number of tests planned
Plan
v
Integer[]

'Test range
SkippedAll
v
b

'Whether the entire test was skipped
Passed
v
i

'Number of successful tests (not accounting for Todo or Skipped ones)
Failed
v
i

'Number of failed tests (not accounting for Todo or Skipped ones)
Todo
v
i

'Number of tested marked as to-do
Skipped
v
i

'Number of skipped tests
Bonus
v
i

'Number of Todo tests which passed
Subtests
v
TestAssertion[]

'Object representation of every assertion
Lines
v
String[]

'A copy of the TAP stream
