Java Unitary tests
Since Scilab 5.3.0 beta1, it is possible to write and launch Java Unitary tests from the source code.
What is a unitary tests ?
Unitary tests are small tests on a class which check the behavior of a method. The Java unitary test system is provided by TestNG.
Where to write tests
Tests must be written per module. They must be stored in:
modules/<module_name>/tests/java/
Any Java file in this directory will be built and executed by the test system.
To ease coherence on the scilab platform, use the org.scilab.tests.modules.<module_name> as a root namespace for your tests. Place them accordingly to the source namespace (eg org.scilab.tests.modules.xcos.utils for testing org.scilab.modules.xcos.utils.* classes).
How to launch tests
ant test
will launch Java Unitary tests and provide a report. Note that any error will stop the build process.
Examples
The HDF5 modules is tested.
$ cd modules/hdf5 && ant test [...] test: [testng] [Parser] Running: [testng] Ant suite [testng] [testng] PASSED: testBooleanMatrix [testng] PASSED: testSingleBoolean [testng] PASSED: emptyMatrix [testng] PASSED: testComplexMatrix [testng] PASSED: testRealMatrix [testng] PASSED: testFakeMetanetGraph [testng] PASSED: testDoubleList [testng] PASSED: testEmptyList [testng] PASSED: testStringList [testng] PASSED: emptyStringTest [testng] PASSED: testSingleString [testng] PASSED: testStringMatrix [testng] [testng] =============================================== [testng] Ant test [testng] Tests run: 12, Failures: 0, Skips: 0 [testng] =============================================== [testng] [testng] [testng] =============================================== [testng] Ant suite [testng] Total tests run: 12, Failures: 0, Skips: 0 [testng] ===============================================