Running Unit Tests in Batch Mode

You can run the JadeUnitTestBatch application:

The arguments following the startAppParameters argument are listed in the following table.

Argument Description
control-file-name Name of the XML control file that defines groups of tests that can be run.
test-name Name of a group of unit tests specified in the control file.
codeCoverage Specifies whether code coverage is enabled or disabled in the JadeUnitTestBatch application. This argument is optional, as you can also specify whether to enable code coverage in the control file.
profile Specifies whether unit test profiling is enabled or disabled in the JadeUnitTestBatch application. This argument is optional, as you can also specify whether to enable unit test profiling in the control file.
log-file-name Name of a log file used for error and test output. This argument is optional, as you can also specify the output destination in the control file.

The control file has the following format.

<unitTest>
   <reporter schema="schema name" class="class name" logFile="file name"/>
    <schema name="test schema name"/>
    <options deltaName="delta name" logCallStack="true" codeCoverage="true" profile="true"/>    <tests>
       <test name="test name">
       ...
       </test>
   </tests>
</unitTest>

The file can also have the following standard XML declaration header.

<?xml version="1.0" encoding="utf-8"?>

The <reporter> XML element is optional, and is used to specify where the unit test output goes. If a schema and class name are specified, they must correspond to a class that implements the JadeTestListenerIF interface. A transient instance of this class is created and the unit test results are passed to the respective interface methods as the tests are run.

If a logFile is specified and is valid, the unit test results are written to this file. If both the schema and class name are specified, they take precedence and the logFile value is ignored. If neither the schema nor class name are specified or are invalid, error output and test result output are written to the log file specified as the third argument in the jadclient command. If the log file is not specified or is invalid, output is written to a file named JadeUnitTest.log in the directory specified by the DefaultLogDirectory parameter in the [JadeMonitorBackground] section of the JADE initialization file.

The <schema> XML element is optional, and is used to specify the default schema in which the unit test classes are defined.

The <options> XML element is optional. You can use it to specify multiple options; for example, <options deltaName="delta name" logCallStack="true" codeCoverage="true"/>.

The <tests> XML element, which must be present, contains one or more <test> XML elements. Each <test> XML element is specified, identifying at least one unit test class to be run.

Tests can also include the contents of other tests, by using the <includeTest> element, as shown in the following example.

<includeTest name="test name"/>

This copies the contents of the test specified by the name attribute into the current test.

The following example shows the structure of a typical <test> XML element.

<unitTest>
    <options deltaName="dawn" logCallStack="true"/>
    <tests>
        <test name="DailyTests">
        <schema name="TestUnitTestSchema"/>
        <class name="UnitTests" includeSubclasses="true"/>
        <class name="WithdrawalTests>
            <method name="overdrawn"/>
            <method name="exceedsLimit"/>
        </class>
        </test>
    </tests>
</unitTest>

The <schema> XML element, which must have a name attribute corresponding to a valid schema, specifies the unit tests to be run for classes in the schema. The <schema> XML element has the optional attributes shown in the following examples.

<schema name="DemoUnitTestSchema" runAllTests="true"/> 
<schema name="DemoUnitTestSchema" runAllTests="true" includeSubschemas="true"/>

The default value of the runAllTests attribute is false. If the runAllTests attribute value is true, all unit test methods of all subclasses of the JadeTestCase class in this schema are run as part of the test. In this case, any <class> XML elements in the test are ignored. The default value of the includeSubschemas attribute is false. If the includeSubschemas attribute value is true, all unit test methods of all subclasses of the JadeTestCase class in this schema and its subschemas are run as part of the test.

The <class> XML element, which must have a name attribute corresponding to a valid subclass of the JadeTestCase class, specifies the unit tests to be run for the class. The variants of this class element are as follows.

The jadclient non-GUI client application returns zero (0) if there were no errors; otherwise it returns an exception code. For example, if one or more tests fail, the exit code is 1467, in which case you can check the JadeUnitTest.log file for details of the failed test or test. Error 1466 is an indication that an incorrect argument was specified; for example, an invalid schema name or test name, and so on.