University of Sheffield

CatWalk: unit testing for Java

Lazy systematic unit testing for agile methods
CatWalk icon

CatWalk Home Page

Start CatWalking...

CatWalk is a tool for lazy systematic unit testing. It performs bounded exhaustive state and equivalence partition testing of any compiled Java class, supplied by the programmer. It tests for full conformance to a lazy specification, which is learned on-the-fly from the code and hints given by the programmer. The tests learned internally may be exported as a JUnit test suite.

Lazy systematic testing is based on the two notions of lazy specification, in which a specification is inferred at the last minute from frequently modified code, and systematic testing, in which the class is rigorously tested, exploring its whole input and state space, using powerful testing algorithms.

CatWalk testing a BankAccount

CatWalk testing a BankAccount

The CatWalk Method

CatWalk can be used right from the outset, as soon as a compiled Java class is ready for testing. After loading the class, you can inspect its public constructor and method protocols, or analyse its algebraic structure, and then explore test sequences of increasing path length. You may then validate the test sequences, in which the tool builds a test oracle from a combination of hints given by the tester and inference rules that predict the class's regular behaviour. Afterwards, testing is fully automatic, up to the learned specification. You may also generate an external JUnit test suite, although CatWalk prefers to regenerate tests internally.

You may start by exploring the algebraic structure of the test class, finding which methods force it into new states, and observing how many input partitions the methods have. This way, you may discover the Complete Behavioural Response of the class. You may then generate tests for this, or for all mutating sequences, or exhaustively for all sequences.

Over a million test sequences may be executed, before CatWalk runs out of memory. If the test class is later modified, CatWalk will quickly re-learn the parts of the specifiction that were altered, making it ideal for agile methods, where the code base is expected to change frequently.

CatWalk versus ToolX

There are other Java testing tools. JUnit is familiar to the agile community. Randoop is used by the random-testing community. EvoSuite is well known in the search-based testing community. CatWalk is different from each of these.

CatWalk thinks up the right test cases that even the expert fails to discover. When the test class is modified or extended by subclassing, CatWalk generates exactly the test cases for all novel interleaved combinations of local and inherited methods. Eventually, a fully trained oracle will detect any mutation made to the test class.