Formatting Batch Commands

Commands are used with the -batch mode option in any one of three formats:

Start the JavaTest harness from a writable directory where you intend to create files and store test results. Include the path of the directory [jt_dir] where the javatest.jar file is installed. The javatest.jar file is usually installed in the TCK lib directory when the JavaTest harness bundled with a TCK.

See Available Batch Commands for a description of the commands that can be used in batch mode.

Batch Options

If you are setting a limited number of batch options you can use the batch options format. In the batch options format, the batch commands are preceded by "-," act as options, and do not use command terminators. Enclose complex batch command arguments in quotes.

Example:

java -jar [jt_dir]/javatest.jar [harness-options] -batch -open default.jti -set host mymachine -runtests

Single String Arguments

If you are setting several batch options, you can use the single string arguments format. In the single string arguments format, one or more batch commands and their arguments can be enclosed in quotes as a single string argument to the -batch option. Multiple batch commands and arguments in the string are separated by semicolons.

Example:

java -jar [jt_dir]/javatest.jar [harness-options] -batch "open default.jti; set host mymachine; runtests"

Batch Command Files

If you are setting a series batch commands and options, you can use the batch command file format. Using the batch command file allows you to easily reuse the same configuration.

In the batch command file format, a file containing a series of batch commands and their arguments is included in the command line by preceding the file name with the "@" symbol. Refer to Creating a Batch Command File below for detailed information about creating a batch command file.

Example:

java -jar [jt_dir]/javatest.jar [harness-options] -batch -open default.jti @batchcmd.jtb

Creating a Batch Command File

You can put a lengthy series of batch commands and their arguments into an ASCII file and then include it in the command line. Using a batch command file allows you to repeatedly use a batch configuration without retyping the commands each time a test run is performed.

To help you identify the function of each batch file, it is recommended that you use a descriptive name and the extension .jtb when naming individual batch files.

Batch files can contain blank lines and comments as well as batch commands and their arguments:

File Contents Description
Comments Comments are started by the # symbol and stop at the end of the line.

Example:
#File contains batch commands

Batch Commands Are executed in the sequence that they appear in the batch file. Use commands listed in Available Batch Commands. Commands used in the batch file must be separated by a semicolon (;) or a new line (#). The # symbol acts as a new line character and can terminate a command.

Examples:
open default.jti #opens file

Example:
open default.jti ; -set host mymachine

Command Arguments Arguments that contain white space must be placed inside quotes. Use "\" to escape special characters such as quotes (") and backslashes (\).

Example Use of a Batch File

An example of a typical application of a batch file:

Use the configuration editor to create a template .jti file and then use it in conjunction with -set commands in a batch file to override specific questions for unique test configurations.

By using a batch file in this manner, it is possible to develop multiple variations of a configuration without having to use the configuration editor each time a minor change is required.