Unit Testing - Invoking Tests and Commandline |
Top Previous Next |
The easiest way to control the invocation of unit testing in your codebase is to let the JrDebugLogger commandline argument parser scan your commandline and invoke it auotmatically:
Unit Testing commandline arguments: -dbt runs all unit tests -dbt "keywords" runs all unit tests matching any of the keywords specified -dbtl lists all registered unit tests along with their keywords and descriptions
For more information about using the commandline parser see the CommandlLine Parsing or CommandLine Parsing Example Topics.
You can also run tests manually from your code. You can also use this approach to design tests that run other subtests:
JrDebug::RunTests(string Keywords); ex. JrDebug::RunTests("all");
Or you can run a function that has never been registered as a test (again these functions must take no arguments and return type void):
JrDebugRunTestFunction(string TestName,FunctionName); ex. JrDebugRunTestFunction("Manual Test#2",MyUnitTest2);
You can call 'bool JrDebug::RanTests()' to see if tests were invoked from the commandline, which can be useful if, for example, you want to have your program exit after tests are run.
|