skip to main content
10.1145/3092703.3092727acmconferencesArticle/Chapter ViewAbstractPublication PagesisstaConference Proceedingsconference-collections
research-article
Open Access
Artifacts Available
Artifacts Evaluated & Functional

Generating unit tests with descriptive names or: would you name your children thing1 and thing2?

Published:10 July 2017Publication History

ABSTRACT

The name of a unit test helps developers to understand the purpose and scenario of the test, and test names support developers when navigating amongst sets of unit tests. When unit tests are generated automatically, however, they tend to be given non-descriptive names such as “test0”, which provide none of the benefits a descriptive name can give a test. The underlying challenge is that automatically generated tests typically do not represent real scenarios and have no clear purpose other than covering code, which makes naming them di cult. In this paper, we present an automated approach which generates descriptive names for automatically generated unit tests by summarizing API-level coverage goals. The tests are optimized to be short, descriptive of the test, have a clear relation to the covered code under test, and allow developers to uniquely distinguish tests in a test suite. An empirical evaluation with 47 participants shows that developers agree with the synthesized names, and the synthesized names are equally descriptive as manually written names. Study participants were even more accurate and faster at matching code and tests with synthesized names compared to manually derived names.

Skip Supplemental Material Section

Supplemental Material

References

  1. S. Afshan, P. McMinn, and M. Stevenson. Evolving readable string test inputs using a natural language model to reduce human oracle cost. In IEEE Int. Conference on Software Testing, Veri�cation and Validation (ICST), pages 352–361, 2013. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. Agitar One, 2016. Last visited on 30.08.2016.Google ScholarGoogle Scholar
  3. M. Allamanis, E. T. Barr, C. Bird, and C. Sutton. Suggesting accurate method and class names. In ACM Symposium on the Foundations of Software Engineering (FSE), pages 38–49, New York, NY, USA, 2015. ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. N. Alshahwan and M. Harman. Augmenting test suites e�ectiveness by increasing output diversity. In ACM/IEEE Int. Conference on Software Engineering (ICSE), pages 1345–1348. IEEE Press, 2012. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. J. H. Andrews, F. C. H. Li, and T. Menzies. Nighthawk: A two-level geneticrandom unit test data generator. In IEEE/ACM Int. Conference on Automated Software Engineering (ASE), pages 144–153. ACM, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. L. Baresi, P. L. Lanzi, and M. Miraz. Testful: An evolutionary test approach for java. In IEEE Int. Conference on Software Testing, Veri�cation and Validation (ICST), pages 185–194. IEEE Computer Society, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. K. H. Bennett and V. T. Rajlich. Software maintenance and evolution: A roadmap. In ACM/IEEE Int. Conference on Software Engineering (ICSE), pages 73–87, New York, NY, USA, 2000. ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. M. Boshernitsan, R. Doong, and A. Savoia. From Daikon to Agitator: Lessons and challenges in building a commercial tool for developer testing. In ACM Int. Symposium on Software Testing and Analysis (ISSTA), pages 169–180. ACM, 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. J. Carver, L. Jaccheri, S. Morasca, and F. Shull. Issues in using students in empirical studies in software engineering education. In IEEE Int. Software Metrics Symposium, pages 239–249, 2003. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. Codepro analytix, 2017. Last visited on 30.01.2017.Google ScholarGoogle Scholar
  11. C. Csallner and Y. Smaragdakis. JCrasher: An automatic robustness tester for java. Softw. Pract. Exper., 34(11):1025–1050, Sept. 2004. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. E. Daka, J. Campos, G. Fraser, J. Dorn, and W. Weimer. Modeling readability to improve unit tests. In ACM Symposium on the Foundations of Software Engineering (FSE), pages 107–118. ACM, 2015. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. G. Fraser and A. Arcuri. EvoSuite: Automatic test suite generation for objectoriented software. In ACM Symposium on the Foundations of Software Engineering (FSE), pages 416–419. ACM, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. G. Fraser and A. Arcuri. Whole test suite generation. IEEE Transactions on Software Engineering (TSE), 39(2):276–291, 2013. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. G. Fraser and A. Arcuri. A large scale evaluation of automated unit test generation using evosuite. ACM Transactions on Software Engineering and Methodology (TOSEM), 24(2):8, 2014. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. G. Fraser and A. Zeller. Exploiting common object usage in test case generation. In IEEE Int. Conference on Software Testing, Veri�cation and Validation (ICST), pages 80–89, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. G. Fraser and A. Zeller. Mutation-driven generation of unit tests and oracles. IEEE Transactions on Software Engineering (TSE), 38(2):278–292, 2012. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. J. P. Galeotti, G. Fraser, and A. Arcuri. Improving search-based test suite generation with dynamic symbolic execution. In IEEE Int. Symposium on Software Reliability Engineering (ISSRE), pages 360–369. IEEE, 2013.Google ScholarGoogle Scholar
  19. E. W. Høst and B. M. Østvold. Debugging method names. In IEEE European Conference on Object-Oriented Programming (ECOOP), volume 5653 of Lecture Notes in Computer Science, pages 294–317. Springer, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. M. Höst, B. Regnell, and C. Wohlin. Using students as subjects—A comparative study of students and professionals in lead-time impact assessment. Empirical Software Engineering, 5(3):201–214, 2000. Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. K. Inkumsah and T. Xie. Evacon: A framework for integrating evolutionary and concolic testing for object-oriented programs. In IEEE/ACM Int. Conference on Automated Software Engineering (ASE), pages 425–428. ACM, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. Parasoft JTest, 2016. Last visited on 30.08.2016.Google ScholarGoogle Scholar
  23. R. Just. The Major mutation framework: E�cient and scalable mutation analysis for Java. In ACM Int. Symposium on Software Testing and Analysis (ISSTA), pages 433–436, 2014. Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. B. A. Kitchenham, S. L. P�eeger, L. M. Pickard, P. W. Jones, D. C. Hoaglin, K. E. Emam, and J. Rosenberg. Preliminary guidelines for empirical research in software engineering. IEEE Transactions on Software Engineering (TSE), 28(8):721– 734, Aug. 2002. Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. Y. Lei and J. H. Andrews. Minimization of randomized unit test cases. In IEEE Int. Symposium on Software Reliability Engineering (ISSRE), pages 267–276. IEEE Computer Society, 2005. Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. A. Leitner, M. Oriol, A. Zeller, I. Ciupa, and B. Meyer. E�cient unit test case minimization. In IEEE/ACM Int. Conference on Automated Software Engineering (ASE), pages 417–420. ACM, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. B. Li, C. Vendome, M. Linares-Vásquez, D. Poshyvanyk, and N. A. Kraft. Automatically documenting unit test cases. In IEEE Int. Conference on Software Testing, Veri�cation and Validation (ICST), pages 341–352, 2016.Google ScholarGoogle ScholarCross RefCross Ref
  28. L. Ma, C. Artho, C. Zhang, H. Sato, J. Gmeiner, and R. Ramler. GRT: An automated test generator using orchestrated program analysis. In IEEE/ACM Int. Conference on Automated Software Engineering (ASE), pages 842–847. IEEE, 2015.Google ScholarGoogle Scholar
  29. M. Oriol and S. Tassis. Testing .NET code with YETI. In R. Calinescu, R. F. Paige, and M. Z. Kwiatkowska, editors, ICECCS, pages 264–265. IEEE Computer Society, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. R. Osherove. The Art of Unit Testing: With Examples in .Net. Manning Publications Co., Greenwich, CT, USA, 1st edition, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  31. C. Pacheco and M. D. Ernst. Randoop: feedback-directed random testing for Java. In ACM SIGPLAN Conference on Object-oriented Programming Systems and Applications Companion (OOPSLA), pages 815–816. ACM, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  32. F. Palomba, A. Panichella, A. Zaidman, R. Oliveto, and A. De Lucia. Automatic test case generation: what if test code quality matters? In ACM Int. Symposium on Software Testing and Analysis (ISSTA), pages 130–141. ACM, 2016. Google ScholarGoogle ScholarDigital LibraryDigital Library
  33. S. Panichella, A. Panichella, M. Beller, A. Zaidman, and H. C. Gall. The impact of test case summaries on bug �xing performance: An empirical investigation. In ACM/IEEE Int. Conference on Software Engineering (ICSE), pages 547–558. ACM, 2016. Google ScholarGoogle ScholarDigital LibraryDigital Library
  34. I. S. W. B. Prasetya. T3, a combinator-based random testing tool for java: Benchmarking. In T. E. J. Vos, K. Lakhotia, and S. Bauersfeld, editors, FITTEST@ICTSS, volume 8432 of Lecture Notes in Computer Science, pages 101–110. Springer, 2013.Google ScholarGoogle Scholar
  35. J. M. Rojas, J. Campos, M. Vivanti, G. Fraser, and A. Arcuri. Combining multiple coverage criteria in search-based unit test generation. In Int. Symposium on Search Based Software Engineering (SSBSE), volume 9275 of LNCS, pages 93–108. Springer, 2015.Google ScholarGoogle Scholar
  36. A. Sakti, G. Pesant, and Y.-G. Guéhéneuc. Instance generator and problem representation to improve object oriented code coverage. IEEE Transactions on Software Engineering (TSE), 41(3):294–313, 2015.Google ScholarGoogle ScholarDigital LibraryDigital Library
  37. I. Salman, A. T. Misirli, and N. Juristo. Are students representatives of professionals in software engineering experiments? In ACM/IEEE Int. Conference on Software Engineering (ICSE), volume 1, pages 666–676, 2015. Google ScholarGoogle ScholarDigital LibraryDigital Library
  38. S. Thummalapenta, T. Xie, N. Tillmann, J. De Halleux, and Z. Su. Synthesizing method sequences for high-coverage testing. ACM SIGPLAN Notices, 46(10):189– 206, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  39. N. Tillmann and J. De Halleux. Pex–white box test generation for. net. In Int. Conference on Tests and Proofs (TAP), pages 134–153. Springer, 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  40. P. Tonella. Evolutionary testing of classes. SIGSOFT Softw. Eng. Notes, 29(4):119– 128, July 2004. Google ScholarGoogle ScholarDigital LibraryDigital Library
  41. A. Trenk. Testing on the toilet: Writing descriptive test names. Computer, Oct. 2014.Google ScholarGoogle Scholar
  42. T. Xie. Augmenting automatically generated unit-test suites with regression oracle checking. In IEEE European Conference on Object-Oriented Programming (ECOOP), pages 380–403. Springer, 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  43. J. Xuan and M. Monperrus. Test case puri�cation for improving fault localization. In ACM Symposium on the Foundations of Software Engineering (FSE), pages 52–63. ACM, 2014. Google ScholarGoogle ScholarDigital LibraryDigital Library
  44. B. Zhang, E. Hill, and J. Clause. Towards automatically generating descriptive names for unit tests. In IEEE/ACM Int. Conference on Automated Software Engineering (ASE), pages 625–636. ACM, 2016. Google ScholarGoogle ScholarDigital LibraryDigital Library
  45. S. Zhang, C. Zhang, and M. Ernst. Automated documentation inference to explain failed tests. In IEEE/ACM Int. Conference on Automated Software Engineering (ASE), pages 63–72, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Generating unit tests with descriptive names or: would you name your children thing1 and thing2?

      Recommendations

      Comments

      Login options

      Check if you have access through your login credentials or your institution to get full access on this article.

      Sign in

      PDF Format

      View or Download as a PDF file.

      PDF

      eReader

      View online with eReader.

      eReader