Chapter 2. Hsqldb Test Utility

The org.hsqldb.test package contains a number of tests for various functions of the database engine. Among these, the TestUtil class performs the tests that are based on scripts. To run the tests, you should compile the hsqldbtest.jar target with Ant and JUnit.

The TestUtil class should be run in the /testrun/hsqldb directory of the distributed files. It then runs the set of TestSelf*.txt files in the directory. To start the application in Windows, change to the directory and type:

 java org.hsqldb.test.TestUtil

All files in the working directory with names matching TestSelf*.txt are processed in alphabetical order.

You can add your own scripts to test different series of SQL queries. The format of the TestSelf*.txt file is simple text, with some indentation and prefixes in the form of Java-style comments. The prefixes indicate what the expected result should be.

The class org.hsqldb.test.TestScriptRunner is a more general program which you can use to test any script files which you specify (with scripts of the same exact format as described below). For example,

java org.hsqldb.test.TestScriptRunner --urlid=mem script1.tsql script2.sql

You must have the HSQLDB classes, including the util and test classes, in your CLASSPATH. The urlid must be set up in an RC file as explained in the RC File Authentication Setup section. Use the rcfile= argument to specify an RC file other than the default of testscriptrunner.rc in the current directory. To see all invocation possibilities, just run TestScriptRunner with no arguments at all. TestScriptRunner can run tests sequentially (the default) or in simultaneous asynchronous threads.

See the TestSelf*.txt files in the /testrun/hsqldb/ directory for actual examples.

The String ${timestamp} may be used in script messages (like in /*d*/, /*w*/, /*p*/). It expands to the current time, down to the second. For example,

/*d*/ It is now ${timestamp}

$Revision: 4904 $