Automated Test Generation for Java Generics

  • Gordon Fraser
  • Andrea Arcuri
Part of the Lecture Notes in Business Information Processing book series (LNBIP, volume 166)

Abstract

Software testing research has resulted in effective white-box test generation techniques that can produce unit test suites achieving high code coverage. However, research prototypes usually only cover subsets of the basic programming language features, thus inhibiting practical use and evaluation. One feature commonly omitted are Java’s generics, which have been present in the language since 2004. In Java, a generic class has type parameters and can be instantiated for different types; for example, a collection can be parameterized with the type of values it contains. To enable test generation tools to cover generics, two simple changes are required to existing approaches: First, the test generator needs to use Java’s extended reflection API to retrieve the little information that remains after type erasure. Second, a simple static analysis can identify candidate classes for type parameters of generic classes. The presented techniques are implemented in the EvoSuite test data generation tool and their feasibility is demonstrated with an example.

Keywords

automated test generation unit testing random testing search-based testing EvoSuite 

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. 1.
    Ali, S., Briand, L., Hemmati, H., Panesar-Walawege, R.: A systematic review of the application and empirical investigation of search-based test-case generation. IEEE Transactions on Software Engineering (TSE) 36(6), 742–762 (2010)CrossRefGoogle Scholar
  2. 2.
    Anand, S., Păsăreanu, C.S., Visser, W.: JPF–SE: A symbolic execution extension to java pathFinder. In: Grumberg, O., Huth, M. (eds.) TACAS 2007. LNCS, vol. 4424, pp. 134–138. Springer, Heidelberg (2007)CrossRefGoogle Scholar
  3. 3.
    Fraser, G., Arcuri, A.: EvoSuite: Automatic test suite generation for object-oriented software. In: ACM Symposium on the Foundations of Software Engineering (FSE), pp. 416–419 (2011)Google Scholar
  4. 4.
    Fraser, G., Arcuri, A.: Sound empirical evidence in software testing. In: ACM/IEEE International Conference on Software Engineering (ICSE), pp. 178–188 (2012)Google Scholar
  5. 5.
    Fraser, G., Arcuri, A.: Whole test suite generation. IEEE Transactions on Software Engineering 39(2), 276–291 (2013)CrossRefGoogle Scholar
  6. 6.
    Fraser, G., Zeller, A.: Mutation-driven generation of unit tests and oracles. IEEE Transactions on Software Engineering (TSE) 28(2), 278–292 (2012)CrossRefGoogle Scholar
  7. 7.
    Godefroid, P., Klarlund, N., Sen, K.: Dart: directed automated random testing. In: ACM Conference on Programming language design and implementation (PLDI), pp. 213–223 (2005)Google Scholar
  8. 8.
    Harman, M., Mansouri, S.A., Zhang, Y.: Search-based software engineering: Trends, techniques and applications. ACM Computing Surveys (CSUR) 45(1), 11 (2012)CrossRefGoogle Scholar
  9. 9.
    Islam, M., Csallner, C.: Dsc+mock: A test case + mock class generator in support of coding against interfaces. In: International Workshop on Dynamic Analysis (WODA), pp. 26–31 (2010)Google Scholar
  10. 10.
    McMinn, P.: Search-based software test data generation: A survey. Software Testing, Verification and Reliability 14(2), 105–156 (2004)CrossRefGoogle Scholar
  11. 11.
    Pacheco, C., Lahiri, S.K., Ernst, M.D., Ball, T.: Feedback-directed random test generation. In: ACM/IEEE International Conference on Software Engineering (ICSE), pp. 75–84 (2007)Google Scholar
  12. 12.
    Parnin, C., Bird, C., Murphy-Hill, E.: Adoption and use of Java generics. Empirical Software Engineering, 1–43 (2012)Google Scholar
  13. 13.
    Tillmann, N., de Halleux, N.J.: Pex — white box test generation for .NET. In: International Conference on Tests And Proofs (TAP), pp. 134–253 (2008)Google Scholar

Copyright information

© Springer International Publishing Switzerland 2014

Authors and Affiliations

  • Gordon Fraser
    • 1
  • Andrea Arcuri
    • 2
  1. 1.Dep. of Computer ScienceUniversity of SheffieldSheffieldUK
  2. 2.Simula Research LaboratoryLysakerNorway

Personalised recommendations