University of Sheffield

CatWalk: unit testing for Java

Lazy systematic unit testing for agile methods
CatWalk icon

CatWalk User Guide

Launch CatWalk

The Java bundle for CatWalk is an executable JAR file that launches the tool out-of-the-box. You should see this (click on any image to zoom):

CatWalk welcome screen

CatWalk welcome screen

Load the Test Class

In the Test Class panel, make sure that the Binary Location is pointing to the root binary folder for the compiled class files that you want to test. This may be called C:/Eclipse/MyProject/bin in Eclipse.

In the Test Class panel, then select the Java package tree leading to the class you want to test. Make sure that the Qualified Name only refers to the full package-qualified name of the test class.

Launch the Locations dialog in the Custom Settings panel, and decide where you wish to save any oracle files. By default, this is under the directory in which you launched CatWalk.

Protocol analysis of a BankAccount

Protocol analysis of a BankAccount

Pick the Test Settings

In the Test Settings panel, the Convention options are:

In the Test Settings panel, the Strategy options are:

Algebraic exploration of a BankAccount

Algebraic exploration of a BankAccount

In the Test Settings panel, the Modality options are:

In the Test Settings panel, the Test Depth spinner sets the maximum test sequence length (default value 3).

For test classes with very large APIs, start low and increase as time and memory permit. Depths of 6-7 are reachable in a class with 10 public methods. Under some test settings, you may explore all possible tests.

Exhaustive validation of a BankAccount

Exhaustive validation of a BankAccount

Run CatWalk

Once you have loaded a test class and picked your test settings, it's time to run your tests.

In the Test Execution panel, hover the mouse over Wilfrid the Cat. If he raises one paw, then you're ready to go. Click on the Cat, and he'll start walking. So long as the Cat is walking, the tool is operating. Once he stops, then the tool has finished, and you can view the results.

If ever Wilfrid slows down, or jitters in his gait, then the tool is approaching memory exhaustion. This need not be a problem - the tool may recover. If memory runs out, it will display all results obtained so far. You may choose to abort a test run by clicking on Cancel.

View the Results

In the large Results tabbed pane, you may view the results of a test run. Click on the appropriate tab to see the following:

Algebraic analysis of a BankAccount

Algebraic analysis of a BankAccount

Histogram analysis for a BankAccount

Histogram analysis for a BankAccount


Test Summary for a BankAccount

Test Summary for a BankAccount

Export to JUnit

If you wish to export a JUnit test suite, there are a few more things to set up. First, ensure that your Java project includes the JUnit library and CatWalk as an external library (otherwise, the generated JUnit test-drivers will have missing Java dependencies).

In the Locations dialog, make sure that the Source Location folder is pointing to the root source folder for the project you want to test. This may be called something like C:/Eclipse/MyProject/src in Eclipse;

In the Locations dialog, select the package under your source root where you want JUnit files to go (otherwise, test drivers will be added to the test class package). Make sure that the Package Name only refers to a package directory tree. After this, you can safely use the Modality: GENERATION.

Pushing CatWalk to memory limits

Pushing CatWalk to memory limits

Configuration

Launch the Configuration dialog in the Custom Settings panel to review rarely-changed configuration options.