Obsidian: Pattern-Based Unit Test Implementations

Abstract

There exist many automated unit test-generator tools for Java with the primary task of generating test cases, comprised of inputs and a corresponding oracle, each of which is explicitly paired with a specific supporting test implementation. The authors posit that this explicit pairing, or conflating, of test implementation with test case is unnecessary and counter-productive. The authors address this problem by separating the conflated concerns into two distinct tasks: 1) instantiating test implementations and 2) instantiating test cases. This paper focuses on automating the first task in support of the second with the goal of freeing the test engineer to concentrate on test case instantiation. The authors present a new open-source test-preparation tool Obsidian that produces robust, comprehensive, and maintainable unit test implementations. Obsidian, built on the JUnit framework, uses a set of context patterns and associated algorithms combined with information from the Java Reflection API to generate these unit test implementations from Java byte code. These context patterns guide Obsidian to prepare test implementations that guarantee compilation, support exception handling, enable multiple test cases when required, and provide a suitable location for assertions about the test case outcome(s). Obsidian supports regression testing and test-driven development through its novel audits of the testing process.

Share and Cite:

J. Bowring and H. Hegler, "Obsidian: Pattern-Based Unit Test Implementations," Journal of Software Engineering and Applications, Vol. 7 No. 2, 2014, pp. 94-103. doi: 10.4236/jsea.2014.72011.

Conflicts of Interest

The authors declare no conflicts of interest.

References

[1] K. Beck, “Extreme Programming Explained: Embrace Change,” Addison-Wesley, Reading, 2000.
[2] K. Beck, “Test-Driven Development: By Example,” Addison-Wesley, Boston, 2003.
[3] B. Robinson, M. D. Ernst, J. H. Perkins,?V. Augustine and N. Li, “Scaling up Automated Test Generation: Automatically Generating Maintainable Regression Unit Tests for Programs,” Proceedings of the 2011 26th IEEE/ACM International Conference on Automated Software Engineering, Washington, 2011, pp. 23-32. http://dx.doi.org/10.1109/ASE.2011.6100059
[4] G. McCluskey, “Using Java Reflection,” 1998. http://java.sun.com/developer/ALT/Reflection/
[5] D. S. Rosenblum, “Towards a Method of Programming with Assertions,” In: Proceedings of the 14th International Conference on Software Engineering, ACM, New York, 1992, pp. 92-104.
http://doi.acm.org/10.1145/143062.143098
[6] G. J. Myers, “The Art of Software Testing,” Wiley, New York, 1979.
[7] G. Fraser and A. Arcuri, “Evosuite: Automatic Test Suitegeneration for Object-Oriented Software,” ACM Symposium on the Foundations of Software Engineering (FSE), 2011, pp. 416-419.
[8] C. Pacheco and M. Ernst, “Randoop: Feedback-Directed Random Testing for Java,” Conference on Object Oriented Programming Systems Languages and Applications: Companion to the 22nd ACM SIGPLAN Conference on Object Oriented Programming Systems and Applications Companion, Vol. 21, 2007, pp. 815-816.
[9] N. Tillmann and J. De Halleux, “Pex-White Box Test Generation for Net,” Tests and Proofs, Vol. 4966, 2008, pp. 134-153.
[10] C. Oriat, “Jartege: A Tool for Random Generation of Unit Tests for Java Classes,” Quality of Software Architectures and Software Quality, Vol. 3712, 2005, pp. 242-256. http://dx.doi.org/10.1007/1155 8569_18
[11] K. Sen and G. Agha, “Cute and Jcute: Concolic Unit Testing and Explicit Path Model-Checking Tools,” Computer Aided Verification, Vol. 4144, 2006, pp. 419-423. http://dx.doi.org/10.1007/11817963_38
[12] C. Csallner and Y. Smaragdakis, “Jcrasher: An Automatic Robustness Tester for Java,” Software: Practice and Experience, Vol. 34, No. 11, 2004, pp. 1025-1050. http://dx.doi.org/10.1002/spe.602
[13] M. Boshernitsan and R. Doong, A. Savoia, “From Daikon to Agitator: Lessons and Challenges in Building a Commercial Tool for Developer Testing,” In: Proceedings of ISSTA 2006, ACM, New York, 2006, pp. 169-180.
[14] Parasoft, Jtest, “Java Static Analysis, Code Review, Unit Testing, Runtime Error Detection.” http://www.parasoft.com/jsp/products/jtest.jsp
[15] C. Pacheco and M. Ernst, “Eclat: AutomatIC Generation and Classification of Test Inputs,” ECOOP Object Oriented Programming, 2005, pp. 734-734.
[16] J. Jones and M. J. Harrold, “Empirical Evaluation of the Tarantula Automatic Fault-Localization Technique,” Proceedings of the 20th IEEE/ACM International Conference on Automated Software Engineering, 2005, pp. 273-282.

Copyright © 2023 by authors and Scientific Research Publishing Inc.

Creative Commons License

This work and the related PDF file are licensed under a Creative Commons Attribution 4.0 International License.