Abstraction in Assertion-Based Test Oracles

Assertions can be used as test oracles. However, writing effective assertions of right abstraction levels is difficult because on the one hand, detailed assertions are preferred for thorough testing (i.e., to detect as many errors as possible), but on the other hand abstract assertions are preferred for readability, maintainability, and reusability. As assertions become a practical tool for testing and debugging programs, this is an important and practical problem to solve for the effective use of assertions. We advocate the use of model variables - specification-only variables of which abstract values are given as mappings from concrete program states - to write abstract assertions for test oracles. We performed a mutation testing experiment to evaluate the effectiveness of the use of model variables in assertion-based test oracles. According to our experiment, assertions written in terms of model variables are as effective as assertions written without using model variables in detecting (injected) faults, and the execution time overhead of model variables are negligible. Our findings are applicable to other use of runtime checkable assertions.

[1]  Stephen H. Edwards,et al.  Model variables: cleanly supporting abstraction in design by contract , 2005, Softw. Pract. Exp..

[2]  Chuck Allison Data abstraction , 1995 .

[3]  K. Rustan M. Leino,et al.  Data abstraction and information hiding , 2002, TOPL.

[4]  Yoonsik Cheon Automated Random Testing to Detect Specification-Code Inconsistencies , 2007, SETP.

[5]  David Lorge Parnas,et al.  Using Test Oracles Generated from Program Documentation , 1998, IEEE Trans. Software Eng..

[6]  Richard G. Hamlet,et al.  Automatically Checking an Implementation against Its Formal Specification , 2000, IEEE Trans. Software Eng..

[7]  Stephen H. Edwards,et al.  Contract-checking wrappers for C++ classes , 2004, IEEE Transactions on Software Engineering.

[8]  Bertrand Meyer,et al.  Eiffel: The Language , 1991 .

[9]  Albert L. Baker,et al.  Preliminary design of JML: a behavioral interface specification language for java , 2006, SOEN.

[10]  Gary T. Leavens,et al.  A Simple and Practical Approach to Unit Testing: The JML and JUnit Way , 2002, ECOOP.

[11]  Wolfram Schulte,et al.  The ABCs of specification: asml, behavior, and components , 2001, Informatica.

[12]  Richard G. Hamlet,et al.  Data Abstraction, Implementation, Specification, and Testing , 1981, TOPL.

[13]  Michael D. Ernst,et al.  An overview of JML tools and applications , 2003, International Journal on Software Tools for Technology Transfer.

[14]  Alexander K. Petrenko,et al.  Java Specification Extension for Automated Test Development , 2001, Ershov Memorial Conference.

[15]  Carlos E. Rubio-Medrano,et al.  Random Test Data Generation for Java Classes Annotated with JML Specifications , 2007, Software Engineering Research and Practice.

[16]  David S. Rosenblum A Practical Approach to Programming With Assertions , 1995, IEEE Trans. Software Eng..

[17]  David Coppit,et al.  On the Use of Specification-Based Assertions as Test Oracles , 2005, 29th Annual IEEE/NASA Software Engineering Workshop.

[18]  C. A. R. Hoare,et al.  An axiomatic basis for computer programming , 1969, CACM.