JWalk is the original tool for lazy systematic unit testing. It performs bounded exhaustive state-based testing of any compiled Java class, supplied by the programmer. It tests both high-level design states and low-level object states. It tests for conformance to a lazy specification, which is learned on-the-fly from the code, by static and dynamic analysis, and from hints supplied by the programmer.
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 up to the specification, exploring its whole state space, using powerful testing algorithms. The testing method is aimed at the agile methods community, for whom the production code and saved tests are the only enduring artifacts.
No formal specification need be produced up-front. The advantage of JWalk over other testing methods is that the tool can automatically infer the test cases that the programmer needs to supply, in order to ensure full state and transition coverage of the inferred specification. JWalk constructs and presents these test cases automatically, saving the programmer time and effort.
JWalk can be used right from the outset, as soon as a prototype class has been compiled.
The programmer follows a feedback-directed approach, first exploring the behaviour of the prototype, generating reports of its behaviour for manual inspection. If the observed behaviour diverges from what was expected, changes can be made to the code. Later, the programmer validates the test class, directing the tools to learn the intended specification incrementally, by a combination of dynamic analysis and limited user-interaction.
As the programmer confirms or rejects key test outcomes, the quality of the learned test oracle improves, eventually allowing JWalk to predict the results of over 90% of new test cases. With a fully trained oracle, testing is completely automated, testing exhaustively up to the inferred specification.
Depending on the test strategy selected, the tools can explore all method protocols (all interleaved method combinations), all algebraic constructions (all sequences that examine the test object in new states) or all high-level states and transitions (where the states are inferred from Boolean predicates in the test class's interface).
Testing can be carried out to an arbitrary depth chosen by the programmer. Finally, if the source code is later modified, the tools can re-learn just the parts of the specification that were changed. So, JWalk is ideally suited to agile methods, where the code base is expected to change frequently.
JWalk exploring all interleaved methods of a Stack
The agile community relies on JUnit, which allows testers to run hand-written regression tests repeatedly on production classes. In a straight comparison with an expert JUnit tester, JWalk was able to test up to two orders of magnitude more cases for the same invested time and effort! This is because JWalk makes better use of test automation:
JUnit merely automates the repeated execution of the saved tests; whereas JWalk proposes all the significant test cases to be covered and executes them systematically.
The JUnit tester has to devise suitable tests by hand, which is hard and error-prone; whereas the JWalk tester only confirms a subset of test outcomes and the tool predicts many more test outcomes automatically.
JUnit's saved regression tests cannot exercise new behaviour introduced later; whereas JWalk generates new tests as soon as the production class's behaviour has been changed.
JWalk takes the effort of thinking up the right test cases away from the tester, by proposing the cases that even the expert fails to discover. When the test class is modified or extended by subclassing, JWalk generates exactly those new test cases that are required for all novel interleaved combinations of local and inherited methods. This is much more discriminating than regression testing using saved tests.
All testing is performed within the tool, that is, there are no exported source-code tests to maintain. Eventually, fully trained test oracles are capable of detecting every mutation made to the code of the test class.
JWalk provides the full power of specification-based conformance testing for programmers who don't want to write formal specifications!