Installing
As the unit testing framework is part of the BTD suite, it
will automatically be installed with the latter. Alternatively it
can be installed stand alone. In both cases the software is
distributed as a package, meaning that after downloading and
unzipping you will find a main directory 'btd' with a number of
subdirectories. This main directory should be copied to a place
where it can be picked up by the Lua path.
Introduction
Unit testing refers to the automated testing of (part of) a program.
With program meaning some unit of code with a specific function, or some
combination of input parameters results in a specific result. The unit
testing framework then, is given a list of test cases (input parameters and
their corresponding results), exercices them, records the results and presents
them in a report. The report gives the number of succeeded and/or failed tests,
the place of the error and the assumption which failed. This should give
the developer enought information to correct the program.
Modules
The entire functionality is covered by four classes :
- Test.lua
-
The test runner. Once the tests are written, this class
is used to run them and to collect the results.
- SWITCHES
-
- errorIDE : IDE integration error format
- verbosity : set verlevel
- help : display a help message
- silent : turn report output off
- COMMANDS
-
- run : test runner, with parameters :
- no parameters : DEPRECATED
- comma separated list of class names
- comma separated list of method names
- report : trigger (new) report output
- reportAll : trigger (all) report output
- clear : clear test statistics
- clearAll : DEPRECATED
- test runner methods
-
- setUpClass : DEPRECATED
- tearDownClass : DEPRECATED
- setUp (optional) : test initialisation
- tearDown (optional) : test clean up
- TestApi.lua
-
The methods and switches used to write test classes.
- differs : result differs from expected result
- equals : result equals expected result
- fails : function should throw an exception
- succeeds : function does not throw an exception
- wrap : wrap functions to a test class
- TestClass.lua
-
Internal use : contains test class LuaNMP code, reporting,...
- TestMethod.lua
-
Internal use : contains test method LuaNMP code, reporting,...