Automatic generation of object oriented unit tests using genetic programming

Automating the generation of object-oriented unit tests for structural testing techniques has been challenging many researchers due to the benefits it promises in terms of cost saving and test quality improvement. It requires test sequences to be generated, each of which models a particular scenario in which the class under test is examined. The generation process aims at obtaining a preferably compact set of test sequences which attains a high degree of structural coverage. The degree of achieved structural coverage indicates the adequacy of the tests and hence the test quality in general. Existing approaches to automatic test generation for object-oriented software mainly rely either on symbolic execution and constraint solving, or on a particular search technique. However, these approaches suffer from various limitations which negatively affect both their applicability in terms of classes for which they are feasible, and their effectiveness in terms of achievable structural coverage. The approaches based on symbolic execution and constraint solving inherit the limitations of these techniques, which are, for instance, issues with scalability and problems with loops, arrays, and complex predicates. The search-based approaches encounter problems in the presence of complex predicates and complex method call dependences. In addition, existing work addresses neither testing non-public methods without breaking data encapsulation, nor the occurrence of runtime exceptions during test generation. Yet, data encapsulation, non-public methods, and exception handling are fundamental concepts of object-oriented software and require also particular consideration for testing. This thesis proposes a new approach to automating the generation of object-oriented unit tests. It employs genetic programming, a recent meta-heuristic optimization technique, which allows formulating the task of test sequence generation as a search problem more suitably than the search techniques applied by the existing approaches. The approach enables testing non-public methods and accounts for runtime exceptions by appropriately designing the objective functions that are used to guide the genetic programming search. The value of the approach is shown by a case study with real-world classes that involve non-public methods and runtime exceptions. The structural coverage achieved by the approach is contrasted with that achieved by a random approach and two commercial test sequence generators. In most of the cases, the approach of this thesis outperformed the other methods.

[1]  秦显忠 机载系统和设备软件适航认证最新指导文件—RTCA DO—178B , 1995 .

[2]  Marat Boshernitsan,et al.  From daikon to agitator: lessons and challenges in building a commercial tool for developer testing , 2006, ISSTA '06.

[3]  Anna Philippou,et al.  Tools and Algorithms for the Construction and Analysis of Systems , 2018, Lecture Notes in Computer Science.

[4]  David L. Spooner,et al.  Automatic Generation of Floating-Point Test Data , 1976, IEEE Transactions on Software Engineering.

[5]  Sarfraz Khurshid,et al.  Generalized Symbolic Execution for Model Checking and Testing , 2003, TACAS.

[6]  C. D. Gelatt,et al.  Optimization by Simulated Annealing , 1983, Science.

[7]  Peter H. Golde,et al.  C# Language Specification , 2003 .

[8]  Al Stevens,et al.  C programming , 1990 .

[9]  Yannis Smaragdakis,et al.  JCrasher: an automatic robustness tester for Java , 2004, Softw. Pract. Exp..

[10]  Bjarne Stroustrup,et al.  C++ Programming Language , 1986, IEEE Softw..

[11]  Mark Harman,et al.  A theoretical & empirical analysis of evolutionary testing and hill climbing for structural test data generation , 2007, ISSTA '07.

[12]  John A. Clark,et al.  An automated framework for structural test-data generation , 1998, Proceedings 13th IEEE International Conference on Automated Software Engineering (Cat. No.98EX239).

[13]  David S. Johnson,et al.  Computers and Intractability: A Guide to the Theory of NP-Completeness , 1978 .

[14]  Leonardo Bottaci Instrumenting Programs With Flag Variables For Test Data Search By Genetic Algorithms , 2002, GECCO.

[15]  Guy L. Steele,et al.  The Java Language Specification , 1996 .

[16]  Mark Harman,et al.  VADA: a transformation-based system for variable dependence analysis , 2002, Proceedings. Second IEEE International Workshop on Source Code Analysis and Manipulation.

[17]  D. E. Goldberg,et al.  Genetic Algorithms in Search , 1989 .

[18]  A. Gray,et al.  I. THE ORIGIN OF SPECIES BY MEANS OF NATURAL SELECTION , 1963 .

[19]  Norbert Oster Automatische Generierung optimaler struktureller Testdaten für objekt-orientierte Software mittels multi-objektiver Metaheuristiken , 2007 .

[20]  K. N. King,et al.  A fortran language system for mutation‐based software testing , 1991, Softw. Pract. Exp..

[21]  Bogdan Korel,et al.  The chaining approach for software test data generation , 1996, TSEM.

[22]  Albert L. Baker,et al.  JML: A Notation for Detailed Design , 1999, Behavioral Specifications of Businesses and Systems.

[23]  Shigeru Chiba,et al.  OpenJava: A Class-Based Macro System for Java , 1999, Reflection and Software Engineering.

[24]  James E. Baker,et al.  Adaptive Selection Methods for Genetic Algorithms , 1985, International Conference on Genetic Algorithms.

[25]  John H. Holland,et al.  Adaptation in Natural and Artificial Systems: An Introductory Analysis with Applications to Biology, Control, and Artificial Intelligence , 1992 .

[26]  Kalyanmoy Deb,et al.  A Comparative Analysis of Selection Schemes Used in Genetic Algorithms , 1990, FOGA.

[27]  Koushik Sen,et al.  CUTE: a concolic unit testing engine for C , 2005, ESEC/FSE-13.

[28]  Mark Harman,et al.  Improving Evolutionary Testing By Flag Removal , 2002, GECCO.

[29]  Rajeev Alur,et al.  A Temporal Logic of Nested Calls and Returns , 2004, TACAS.

[30]  Nikolai Tillmann,et al.  Unit tests reloaded: parameterized unit testing with symbolic execution , 2006, IEEE Software.

[31]  Michael O'Neill,et al.  Grammatical Evolution: Evolving Programs for an Arbitrary Language , 1998, EuroGP.

[32]  Walter Böhm,et al.  Exact Uniform Initialization For Genetic Programming , 1996, FOGA.

[33]  James E. Baker,et al.  Reducing Bias and Inefficienry in the Selection Algorithm , 1987, ICGA.

[34]  André Baresel,et al.  Structural and Functional Sequence Test of Dynamic and State-Based Software with Evolutionary Algorithms , 2003, GECCO.

[35]  Sarfraz Khurshid,et al.  Test input generation with java PathFinder , 2004, ISSTA '04.

[36]  Bin Wang,et al.  A unified fitness function calculation rule for flag conditions to improve evolutionary testing , 2005, ASE '05.

[37]  David Notkin,et al.  Symstra: A Framework for Generating Object-Oriented Unit Tests Using Symbolic Execution , 2005, TACAS.

[38]  Phil McMinn,et al.  Search‐based software test data generation: a survey , 2004, Softw. Test. Verification Reliab..

[39]  John A. Clark,et al.  Assessing Test Set Adequacy for Object-Oriented Programs Using Class Mutation , 2000 .

[40]  Joachim Wegener,et al.  Evolutionary test environment for automatic structural testing , 2001, Inf. Softw. Technol..

[41]  Volker Gruhn,et al.  BINTEST - Binary Search-based Test Case Generation , 2003 .

[42]  Wolfgang Banzhaf,et al.  Genetic Programming: An Introduction , 1997 .

[43]  Bjarne Stroustrup What Is Object-Oriented Programming? , 1988, IEEE Softw..

[44]  W BoehmBarry A Spiral Model of Software Development and Enhancement , 1988 .

[45]  Bogdan Korel,et al.  Automated Software Test Data Generation , 1990, IEEE Trans. Software Eng..

[46]  James C. King,et al.  Symbolic execution and program testing , 1976, CACM.

[47]  Mark Harman,et al.  Evolutionary testing in the presence of loop-assigned flags: a testability transformation approach , 2004, ISSTA '04.

[48]  Harmen-Hinrich Sthamer,et al.  The automatic generation of software test data using genetic algorithms , 1995 .

[49]  Philip McMinn,et al.  Evolutionary search for test data in the presence of state behaviour , 2005 .

[50]  John R. Koza,et al.  Genetic programming - on the programming of computers by means of natural selection , 1993, Complex adaptive systems.

[51]  Edward P. K. Tsang,et al.  Foundations of constraint satisfaction , 1993, Computation in cognitive science.

[52]  M. E. Staknis Software quality assurance through prototyping and automated testing , 1990 .

[53]  André Baresel,et al.  Evolutionary Testing of Flag Conditions , 2003, GECCO.

[54]  John A. Clark,et al.  Automated program flaw finding using simulated annealing , 1998, ISSTA '98.

[55]  Koushik Sen,et al.  CUTE and jCUTE: Concolic Unit Testing and Explicit Path Model-Checking Tools , 2006, CAV.

[56]  Hartmut Pohlheim,et al.  Ein genetischer Algorithmus mit Mehrfachpopulationen zur Numerischen Optimierung , 1995 .

[57]  M. F.,et al.  Bibliography , 1985, Experimental Gerontology.

[58]  David J. Montana,et al.  Strongly Typed Genetic Programming , 1995, Evolutionary Computation.

[59]  Peter Norvig,et al.  Artificial Intelligence: A Modern Approach , 1995 .

[60]  Anas N. Al-Rabadi,et al.  A comparison of modified reconstructability analysis and Ashenhurst‐Curtis decomposition of Boolean functions , 2004 .

[61]  Sigrid Eldh Software Testing Techniques , 2007 .

[62]  Phil McMinn,et al.  Evolutionary Testing Using an Extended Chaining Approach , 2006, Evolutionary Computation.

[63]  Roger L. Wainwright,et al.  Type inheritance in strongly typed genetic programming , 1996 .

[64]  Bryan F. Jones,et al.  Automatic structural testing using genetic algorithms , 1996, Softw. Eng. J..

[65]  Paolo Tonella,et al.  Evolutionary testing of classes , 2004, ISSTA '04.

[66]  Lawrence J. Fogel,et al.  Artificial Intelligence through Simulated Evolution , 1966 .

[67]  A. E. Eiben,et al.  Introduction to Evolutionary Computing , 2003, Natural Computing Series.

[68]  Ingo Rechenberg,et al.  Evolutionsstrategie : Optimierung technischer Systeme nach Prinzipien der biologischen Evolution , 1973 .

[69]  André Baresel,et al.  Fitness Function Design To Improve Evolutionary Structural Testing , 2002, GECCO.

[70]  Baowen Xu,et al.  Application of Genetic Algorithms in Software Testing , 2007 .

[71]  Andrew R. McIntyre,et al.  Resource Review: Three Open Source Systems for Evolving Programs–Lilgp, ECJ and Grammatical Evolution , 2004, Genetic Programming and Evolvable Machines.

[72]  David E. Goldberg,et al.  Genetic Algorithms in Search Optimization and Machine Learning , 1988 .

[73]  Alessandro Orso,et al.  Automated Testing of Classes , 2000, ISSTA '00.

[74]  John A. Clark,et al.  Investigating the effectiveness of object‐oriented testing strategies using the mutation method , 2001, Softw. Test. Verification Reliab..

[75]  Gary McGraw,et al.  Generating Software Test Data by Evolution , 2001, IEEE Trans. Software Eng..

[76]  Robert V. Binder,et al.  Testing Object-Oriented Systems: Models, Patterns, and Tools , 1999 .

[77]  John A. Clark,et al.  INVESTIGATING THE APPLICABILITY OF TRADITIONAL TEST ADEQUACY CRITERIA FOR OBJECT-ORIENTED PROGRAMS , 2000 .

[78]  Roy P. Pargas,et al.  Test-Data Generation Using Genetic Algorithms , 1999, Softw. Test. Verification Reliab..

[79]  Heinz Mühlenbein,et al.  Predictive Models for the Breeder Genetic Algorithm I. Continuous Parameter Optimization , 1993, Evolutionary Computation.

[80]  Matthew S. Hecht,et al.  Flow Analysis of Computer Programs , 1977 .

[81]  Kent L. Beck,et al.  Test-driven Development - by example , 2002, The Addison-Wesley signature series.