Skip to main content
Log in

GenUTest: a unit test and mock aspect generation tool

  • Regular Paper
  • Published:
International Journal on Software Tools for Technology Transfer Aims and scope Submit manuscript

Abstract

Unit testing plays a major role in the software development process. What started as an ad hoc approach is becoming a common practice among developers. It enables the immediate detection of bugs introduced into a unit whenever code changes occur. Hence, unit tests provide a safety net of regression tests and validation tests which encourage developers to refactor existing code with greater confidence. One of the major corner stones of the agile development approach is unit testing. Agile methods require all software classes to have unit tests that can be executed by an automated unit-testing framework. However, not all software systems have unit tests. When changes to such software are needed, writing unit tests from scratch, which is hard and tedious, might not be cost effective. In this paper we propose a technique which automatically generates unit tests for software that does not have such tests. We have implemented GenUTest, a prototype tool which captures and logs interobject interactions occurring during the execution of Java programs, using the aspect-oriented language AspectJ. These interactions are used to generate JUnit tests. They also serve in generating mock aspects—mock object-like entities, which enable testing units in isolation. The generated JUnit tests and mock aspects are independent of the tool, and can be used by developers to perform unit tests on the software. Comprehensiveness of the unit tests depends on the software execution. We applied GenUTest to several open source projects such as NanoXML and JODE. We present the results, explain the limitations of the tool, and point out direction to future work to improve the code coverage provided by GenUTest and its scalability.

This is a preview of subscription content, log in via an institution to check access.

Access this article

Price excludes VAT (USA)
Tax calculation will be finalised during checkout.

Instant access to the full article PDF.

Similar content being viewed by others

References

  1. Andrews, J.H., Haldar, S., Lei, Y., Li, F.C.H.: Tool support for randomized unit testing. In: Proceedings of the 1st International Workshop on Random Testing, pp. 36–45 (2006)

  2. Arrays (Java 2 Platform SE 5.0).: http://java.sun.com/j2se/1.5.0/docs/api/java/util/Arrays.html. Accessed Jan 2009

  3. AspectJ.: http://www.eclipse.org/aspectj. Accessed Jan 2009

  4. Beckert, B., Hähnle, R., Schmitt, P.H. (eds.): Verification of Object-Oriented Software: The KeY Approach. Lecture Notes in Computer Science, vol. 4334. Springer, Berlin (2007)

  5. Boshernitsan, M., Doong, R., Savoia, A.: From Daikon to Agitator: lessons and challenges in building a commercial tool for developer testing. In: Proceedings of the International Symposium on Software Testing and Analysis, pp. 169–180 (2006)

  6. Clifton, M.: Advanced Unit Test, Part V—Unit Test Patterns, January 2004. http://www.codeproject.com/gen/design/autp5.asp. Accessed Jan 2009

  7. Commons Lang.: http://commons.apache.org/lang. Accessed Jan 2009

  8. Csallner C., Smaragdakis Y.: JCrasher: an automatic robustness tester for Java. Softw. Pract. Experience 34(11), 1025–1050 (2004)

    Article  Google Scholar 

  9. d’Amorim, M., Pacheco, C., Xie, T., Marinov, D., Ernst, M.: An empirical comparison of automated generation and classification techniques for object-oriented unit testing. In: Proceedings of the 21st IEEE/ACM International Conference on Automated Software Engineering (ASE 2006), pp. 59–68 (2006)

  10. Easy Mock.: http://www.easymock.org. Accessed Jan 2009

  11. EclEmma.: http://www.eclemma.org. Accessed Jan 2009

  12. Eclipse.: http://www.eclipse.org. Accessed Jan 2009

  13. Elbaum, S., Chin, H.N., Dwyer, M.B., Dokulil, J.: Carving differential unit test cases from system test cases. In: Proceedings of the 14th ACM SIGSOFT International Symposium on Foundations of Software Engineering, pp. 253–264 (2006)

  14. Extreme Programming.: http://www.extremeprogramming.org. Visited January (2009)

  15. Fowler M.: Refactoring: Improving the Design of Existing Code. Addison-Wesley, Reading (2000)

    Google Scholar 

  16. Gamma E., Helm R., Johnson R., Vlissides J.: Design Patterns: Elements of Reusable Object-Oriented Software. Addison-Wesley, Reading (1995)

    Google Scholar 

  17. Husted T., Massol V.: JUnit in Action. Manning Publications, Greenwich (2003)

    Google Scholar 

  18. HP WinRunner software.: http://www.hp.com. Accessed Jan 2009

  19. IdentityHashMap (Java 2 Platform SE 5.0).: http://java.sun.com/j2se/1.5.0/docs/api/java/util/IdentityHashMap.html. Accessed Jan 2009

  20. Intel VTune Performance Analyzer.: http://www.intel.com/cd/software/products/asmo-na/eng/239144.htm. Accessed Jan 2009

  21. Java programming dynamics, Part 2: Introducing reflection.: http://www-128.ibm.com/developerworks/java/library/j-dyn0603. Accessed Jan 2009

  22. JODE (Java Optimize and Decompile Environment).: http://jode.sourceforge.net. Accessed Jan 2009

  23. JUnit.: http://www.junit.org. Accessed Jan 2009

  24. Kiczales, G., Lamping, J., Mendhekar, A., Maeda, C., Lopes, C., Loingtier, J.M., Irwin, J.: Aspect-oriented programming. In: Proceedings of the 11th European Conference on Object-Oriented Programming (ECOOP), Jyväskylä, Finland (1997)

  25. Laddad R.: AspectJ in Action: Practical Aspect-Oriented Programming. Manning Publications, Greenwich (2003)

    Google Scholar 

  26. Mackinnon, T., Freeman, S., Craig, P.: Endo-testing: unit testing with mock objects. In: Extreme Programming Examined, pp. 287–301. Addison-Wesley, Reading (2001)

  27. Monk, S., Hall, S.: Virtual Mock Objects using AspectJ with JUnit, 2002. http://www.xprogramming.com/xpmag/virtualMockObjects.htm. Accessed January 2009

  28. NanoXML.: http://nanoxml.cyberelf.be. Accessed Jan 2009

  29. Oriat, C.: Jartege: a tool for random generation of unit tests for Java classes. In: Proceedings of the Second International Workshop on Software Quality (SOQUA), pp. 242–256 (2005)

  30. Orso, A., Kennedy, B.: Selective capture and replay of program executions. In: Proceedings of the Workshop on Dynamic Analysis, pp. 1–7 (2005)

  31. Pacheco, C., Ernst, M.: Eclat: automatic generation and classification of test inputs. In: Proceedings of the 19th European Conference on Object-Oriented Programming (ECOOP), Glasgow, Scotland, pp. 504–527(2005)

  32. Pasternak, B., Tyszberowicz, S., Yehudai, A.: GenUTest: a unit test and mock aspect generation tool. In: Proceedings of Haifa Verification Conference, Lecture Notes in Computer Science, vol. 4899, pp. 252–266. Springer, Berlin (2007)

  33. Saff, D., Artzi, S., Perkins, J., Ernst, M.: Automated test factoring for Java. In: Conference of Automated Software Engineering (ASE), pp. 114–123 (2005)

  34. Steven, J., Chandra, P., Fleck, B., Podgurski, A.: jRapture: a Capture/Replay tool for observation-based testing. In: Proceedings of the International Symposium on Software Testing and Analysis, pp. 158–167 (2000)

  35. String (Java 2 Platform SE 5.0).: http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html. Accessed Jan 2009

  36. The Daikon invariant detector.: http://groups.csail.mit.edu/pag/daikon. Accessed Jan 2009

  37. van Vliet H.: Software Engineering: Principles and Practice. 2nd edn. Wiley, New York (2000)

    Google Scholar 

  38. Visser, W., Pǎsǎreanu, C.S., Khurshid, S.: Test input generation with Java PathFinder. In: Proceedings of the ACM SIGSOFT International Symposium on Software Testing and Analysis, pp. 97–107 (2004)

  39. Xie, T., Marinov, D., Notkin, D.: Rostra: A framework for detecting redundant object-oriented unit tests. In: Proceedings of the 19th IEEE International Conference on Automated Software Engineering (ASE), pp. 196–205 (2004)

  40. Xie, T., Marinov, D., Schulte, W., Notkin, D.: Symstra: A framework for generating object-oriented unit tests using symbolic execution. In: Proceedings of the International Conference on Tools and Algorithms for the Construction and Analysis of Systems (TACAS) (2005)

  41. XStream 1.2.2.: http://xstream.codehaus.org. Accessed Jan 2009

  42. Yuan, H., Xie, T.: Substra: a framework for automatic generation of integration tests. In: Proceedings of the International Workshop on Automation of Software Test, pp. 64–70 (2006)

Download references

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Shmuel Tyszberowicz.

Rights and permissions

Reprints and permissions

About this article

Cite this article

Pasternak, B., Tyszberowicz, S. & Yehudai, A. GenUTest: a unit test and mock aspect generation tool. Int J Softw Tools Technol Transfer 11, 273–290 (2009). https://doi.org/10.1007/s10009-009-0115-4

Download citation

  • Published:

  • Issue Date:

  • DOI: https://doi.org/10.1007/s10009-009-0115-4

Keywords

Navigation