Running Unit Tests from an Application
You can run tests from code, by creating an instance of the
The following example shows tests being run for the TestCalculator class.
vars tests : ObjectArray; jtr : JadeTestRunner; begin create tests transient; tests.add(TestCalculator); create jtr transient; jtr.runTests(tests); epilog delete tests; delete jtr; end;
The following example shows tests being run for the TestConvertor class and for two unit test methods of the TestCalculator class.
vars tests : ObjectArray; jtr : JadeTestRunner; begin create tests transient; tests.add(TestConvertor); tests.add(TestCalculator::add); tests.add(TestCalculator::divide); create jtr transient; jtr.runTests(tests); epilog delete tests; delete jtr; end;
The destination and format of the output from the
If a test listener is present, the implementation of the interface methods determines the destination and format of the output. If there is no test listener, test results are written to the Jade Interpreter Output Viewer window. The following output is produced from the TestCalculator unit tests without a test listener.
hello FAIL: TestCalc::divide - assertEquals - expected 5 but actual= 4 FAIL: TestCalc::subtract - assertEquals - expected 8 but actual= 9 bye bye Summary FAILURES!!! Total tests run: 6, Ignored: 1, Failures: 2
For more details about setting up a test listener, see "Listening for Unit Test Results", in the following section.