The hidden states of objects create a barrier to designing and generating test data automatically. For example, the state of an object has to be established indirectly through a sequence of method invocations. For a non-trivial class, however, it is extremely difficult for a randomly-chosen sequence of method invocations to construct an object successfully, as each invocation has to satisfy the state invariants. Nonetheless, automated random testing can reduce the cost of testing dramatically and has strong potential for finding errors that are difficult to find in other ways because it eliminates the subjectiveness in constructing test data. We propose a new approach to generating test data automatically for Java classes annotated with JML specifications. The key idea underlying our approach is to construct an object incrementally in that each method call in the sequence is checked before the next call is chosen. We use JML’s runtime assertion checker to check the validity of a method invocation. Other ingredients of our approach include object pooling and object equivalence checking. These are to increase the probability of constructing feasible call sequences and to remove redundancy among the successfullybuilt sequences. We have implemented our approach for JET, a fully-automated testing tool for Java, and our experiment with JET showed a promising result, 10 to 200% increase in the number of generated test cases.
[1]
Albert L. Baker,et al.
JML: A Notation for Detailed Design
,
1999,
Behavioral Specifications of Businesses and Systems.
[2]
David Notkin,et al.
Rostra: a framework for detecting redundant object-oriented unit tests
,
2004,
Proceedings. 19th International Conference on Automated Software Engineering, 2004..
[3]
Michael D. Ernst,et al.
Eclat: Automatic Generation and Classification of Test Inputs
,
2005,
ECOOP.
[4]
Gary T. Leavens,et al.
A Simple and Practical Approach to Unit Testing: The JML and JUnit Way
,
2002,
ECOOP.
[5]
Yoonsik Cheon.
Automated Random Testing to Detect Specification-Code Inconsistencies
,
2007,
SETP.
[6]
Yannis Smaragdakis,et al.
JCrasher: an automatic robustness tester for Java
,
2004,
Softw. Pract. Exp..
[7]
John D. McGregor,et al.
A Practical Guide to Testing Object-Oriented Software
,
2001,
Addison Wesley object technology series.
[8]
Albert L. Baker,et al.
Preliminary design of JML: a behavioral interface specification language for java
,
2006,
SOEN.
[9]
David Lorge Parnas,et al.
Using Test Oracles Generated from Program Documentation
,
1998,
IEEE Trans. Software Eng..
[10]
Software and Component Testing: Using Jtest ® to Automate Unit Testing and Coding Standard Enforcement
,
.