Automatic Extraction of Object-Oriented Observer Abstractions from Unit-Test Executions

  • Tao Xie
  • David Notkin
Part of the Lecture Notes in Computer Science book series (LNCS, volume 3308)


Unit testing has become a common step in software development. Although manually created unit tests are valuable, they are often insufficient; therefore, programmers can use an automatic unit-test-generation tool to produce a large number of additional tests for a class. However, without a priori specifications, programmers cannot practically inspect the execution of each automatically generated test. In this paper, we develop the observer abstraction approach for automatically extracting object-state-transition information of a class from unit-test executions, without requiring a priori specifications. Given a class and a set of its initial tests generated by a third-party tool, we generate new tests to augment the initial tests and produce the abstract state of an object based on the return values of a set of observers (public methods with non-void returns) invoked on the object. From the executions of both the new and initial tests, we automatically extract observer abstractions, each of which is an object state machine (OSM): a state in the OSM represents an abstract state and a transition in the OSM represents method calls. We have implemented the Obstra tool for the approach and have applied the approach on complex data structures; our experiences suggest that this approach provides useful object-state-transition information for programmers to inspect unit-test executions effectively.


State Machine Abstract State Test Suite Object State Method Call 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. 1.
    Ammons, G., Bodik, R., Larus, J.R.: Mining specifications. In: Proc. the 29th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, pp. 4–16 (2002)Google Scholar
  2. 2.
    Arnold, K., Gosling, J., Holmes, D.: The Java Programming Language. Addison-Wesley Longman Publishing Co. Inc., Amsterdam (2000)Google Scholar
  3. 3.
    Ball, T., Majumdar, R., Millstein, T., Rajamani, S.K.: Automatic predicate abstraction of C programs. In: Proc. the ACM SIGPLAN 2001 Conference on Programming Language Design and Implementation, pp. 203–213 (2001)Google Scholar
  4. 4.
    Boyapati, C., Khurshid, S., Marinov, D.: Korat: automated testing based on Java predicates. In: Proc. the International Symposium on Software Testing and Analysis, pp. 123–133 (2002)Google Scholar
  5. 5.
    Csallner, C., Smaragdakis, Y.: JCrasher documents. Online manual (December 2003)Google Scholar
  6. 6.
    Dahm, M., van Zyl, J.: Byte Code Engineering Library (April 2003),
  7. 7.
    Ernst, M.D., Cockrell, J., Griswold, W.G., Notkin, D.: Dynamically discovering likely program invariants to support program evolution. IEEE Trans. Softw. Eng. 27(2), 99–123 (2001)CrossRefGoogle Scholar
  8. 8.
    Gansner, E.R., North, S.C.: An open graph visualization system and its applications to software engineering. Software: Practice and Experience 30(11), 1203–1233 (2000)zbMATHCrossRefGoogle Scholar
  9. 9.
    Graf, S., Saidi, H.: Construction of abstract state graphs with PVS. In: Proc. the 9th International Conference on Computer Aided Verification, pp. 72–83 (1997)Google Scholar
  10. 10.
    Grieskamp, W., Gurevich, Y., Schulte, W., Veanes, M.: Generating finite state machines from abstract state machines. In: Proc. the International Symposium on Software Testing and Analysis, pp. 112–122 (2002)Google Scholar
  11. 11.
    Gupta, N., Mathur, A.P., Soffa, M.L.: Automated test data generation using an iterative relaxation method. In: Proc. the 6th ACM SIGSOFT International Symposium on Foundations of Software Engineering, pp. 231–244 (1998)Google Scholar
  12. 12.
    Henkel, J., Diwan, A.: Discovering algebraic specifications from Java classes. In: Proc. the 17th European Conference on Object-Oriented Programming, pp. 431–456 (2003)Google Scholar
  13. 13.
    JUnit (2003),
  14. 14.
    Kung, D., Suchak, N., Gao, J., Hsia, P.: On object state testing. In: Proc. the 18th Annual International Computer Software and Applications Conference, pp. 222–227 (1994)Google Scholar
  15. 15.
    Lee, D., Yannakakis, M.: Principles and methods of testing finite state machines - A survey. In: Proc. The IEEE, vol. 84, August 1996, pp. 1090–1123 (1996)Google Scholar
  16. 16.
    Liskov, B., Guttag, J.: Program Development in Java: Abstraction, Specification, and Object-Oriented Design. Addison-Wesley, Reading (2000)Google Scholar
  17. 17.
    Nguyen, D.: Design patterns for data structures. In: Proc. the 29th SIGCSE Technical Symposium on Computer Science Education, pp. 336–340 (1998)Google Scholar
  18. 18.
    Parasoft. Jtest manuals version 4.5. Online manual (April 2003),
  19. 19.
    Sun Microsystems. Java 2 Platform, Standard Edition, v 1.4.2, API Specification. Online documentation (November 2003),
  20. 20.
    Turner, C.D., Robson, D.J.: The state-based testing of object-oriented programs. In: Proc. the Conference on Software Maintenance, pp. 302–310 (1993)Google Scholar
  21. 21.
    Whaley, J., Martin, M.C., Lam, M.S.: Automatic extraction of object-oriented component interfaces. In: Proc. the International Symposium on Software Testing and Analysis, pp. 218–228 (2002)Google Scholar
  22. 22.
    Xie, T., Marinov, D., Notkin, D.: Improving generation of object-oriented test suites by avoiding redundant tests. Technical Report UW-CSE-04-01-05, University of Washington Department of Computer Science and Engineering, Seattle, WA (January 2004)Google Scholar
  23. 23.
    Xie, T., Marinov, D., Notkin, D.: Rostra: A framework for detecting redundant object-oriented unit tests. In: Proc. 19th IEEE International Conference on Automated Software Engineering (2004)Google Scholar
  24. 24.
    Xie, T., Notkin, D.: Mutually enhancing test generation and specification inference. In: Petrenko, A., Ulrich, A. (eds.) FATES 2003. LNCS, vol. 2931, pp. 60–69. Springer, Heidelberg (2004)CrossRefGoogle Scholar
  25. 25.
    Xie, T., Notkin, D.: Tool-assisted unit test selection based on operational violations. In: Proc. 18th IEEE International Conference on Automated Software Engineering, pp. 40–48 (2003)Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2004

Authors and Affiliations

  • Tao Xie
    • 1
  • David Notkin
    • 1
  1. 1.Department of Computer Science & EngineeringUniversity of WashingtonSeattleUSA

Personalised recommendations