Mutation Testing G. Rothermel. Fault-Based Testing White-box and black-box testing techniques use coverage of code or requirements as a “proxy” for designing.

Slides:



Advertisements
Similar presentations
Verification and Validation
Advertisements

White-Box Testing Techniques IV
Practical Testing Techniques. Verification and Validation Validation –does the software do what was wanted? “Are we building the right system?” –This.
MUTATION TESTING. Mutation testing is a technique that focuses on measuring the adequacy (quality) of test data (or test cases). Modify a program by introducing.
(c) 2007 Mauro Pezzè & Michal Young Ch 9, slide 1 Test Case Selection and Adequacy Criteria.
An Analysis and Survey of the Development of Mutation Testing by Yue Jia and Mark Harmon A Quick Summary For SWE6673.
Unit Testing CSSE 376, Software Quality Assurance Rose-Hulman Institute of Technology March 27, 2007.
1 Software Testing and Quality Assurance Lecture 9 - Software Testing Techniques.
Software Testing Using Model Program DESIGN BY HONG NGUYEN & SHAH RAZA Dec 05, 2005.
Ch6: Software Verification. 1 Statement coverage criterion  Informally:  Formally:  Difficult to minimize the number of test cases and still ensure.
(c) 2007 Mauro Pezzè & Michal Young Ch 16, slide 1 Fault-Based Testing.
Introduction to Hypothesis Testing
1CMSC 345, Version 4/04 Verification and Validation Reference: Software Engineering, Ian Sommerville, 6th edition, Chapter 19.
1 Functional Testing Motivation Example Basic Methods Timing: 30 minutes.
Language Evaluation Criteria
System/Software Testing
Introduction to Software Testing Chapter 5.2 Program-based Grammars Paul Ammann & Jeff Offutt
Software Testing and Validation SWE 434
Kyle Mundt February 3,  Richard Lipton, 1971  A way of testing your tests  Alter your code in various ways  Check to see if tests fail on altered.
© SERG Dependable Software Systems (Mutation) Dependable Software Systems Topics in Mutation Testing and Program Perturbation Material drawn from [Offutt.
Coverage – “Systematic” Testing Chapter 20. Dividing the input space for failure search Testing requires selecting inputs to try on the program, but how.
Foundations of Software Testing Chapter 5: Test Selection, Minimization, and Prioritization for Regression Testing Last update: September 3, 2007 These.
Requirements-based Test Generation for Functional Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 1 W. Eric Wong Department.
What is Mutation Testing ? The premise in mutation testing is that small changes are made in a module and then the original and mutant modules are compared.
Software testing techniques Software testing techniques Mutation testing Presentation on the seminar Kaunas University of Technology.
COMP 121 Week 1: Testing and Debugging. Testing Program testing can be used to show the presence of bugs, but never to show their absence! ~ Edsger Dijkstra.
Testing Testing Techniques to Design Tests. Testing:Example Problem: Find a mode and its frequency given an ordered list (array) of with one or more integer.
Test Drivers and Stubs More Unit Testing Test Drivers and Stubs CEN 5076 Class 11 – 11/14.
Test Coverage CS-300 Fall 2005 Supreeth Venkataraman.
White-box Testing.
Software Metric; defect removal efficiency, Cyclomate Complexity Defect Seeding Mutation Testing.
Chapter 1: Fundamental of Testing Systems Testing & Evaluation (MNN1063)
Software Testing Part II March, Fault-based Testing Methodology (white-box) 2 Mutation Testing.
Software Testing Syntax-based Testing. Syntax Coverage Four Structures for Modeling Software Graphs Logic Input Space Syntax Use cases Specs Design Source.
Introduction to Software Testing Chapter 9.2 Program-based Grammars Paul Ammann & Jeff Offutt
Software Construction Lecture 19 Software Testing-2.
Week 5-6 MondayTuesdayWednesdayThursdayFriday Testing III No reading Group meetings Testing IVSection ZFR due ZFR demos Progress report due Readings out.
Foundations of Software Testing Slides based on: Draft V4.0. November 19, 2006 Test Adequacy Measurement and Enhancement Using Mutation Last update: January15,
1 © 2011 Professor W. Eric Wong, The University of Texas at Dallas Requirements-based Test Generation for Functional Testing W. Eric Wong Department of.
Mutation Testing Breaking the application to test it.
Software Testing Sudipto Ghosh CS 406 Fall 99 November 23, 1999.
Foundations of Software Testing Chapter 7: Test Adequacy Measurement and Enhancement Using Mutation Last update: September 3, 2007 These slides are copyrighted.
Foundations of Software Testing Chapter 5: Test Selection, Minimization, and Prioritization for Regression Testing Last update: September 3, 2007 These.
MUTACINIS TESTAVIMAS Benediktas Knispelis, IFM-2/2 Mutation testing.
Foundations of Software Testing Chapter 7: Test Adequacy Measurement and Enhancement Using Mutation Last update: September 3, 2007 These slides are copyrighted.
Mutation Testing Laraib Zahid & Mariam Arshad. What is Mutation Testing?  Fault-based Testing: directed towards “typical” faults that could occur in.
Software Testing. SE, Testing, Hans van Vliet, © Nasty question  Suppose you are being asked to lead the team to test the software that controls.
1 Software Testing. 2 What is Software Testing ? Testing is a verification and validation activity that is performed by executing program code.
Software Testing and Quality Assurance Syntax-Based Testing (2) 1.
Foundations of Software Testing Slides based on: Draft V1.0 August 17, 2005 Test Adequacy Measurement and Enhancement Using Mutation Last update: October.
Introduction to Software Testing (2nd edition) Chapter 5 Criteria-Based Test Design Paul Ammann & Jeff Offutt
Regression Testing with its types
Generating Automated Tests from Behavior Models
White-Box Testing Techniques IV
Introduction to Software Testing Chapter 9.2 Program-based Grammars
Mutation Testing Moonzoo Kim School of Computing KAIST
Mutation testing Julius Purvinis IFM-0/2.
Faults, Errors, Failures CS 4501 / 6501 Software Testing
UNIT-4 BLACKBOX AND WHITEBOX TESTING
Introduction to Software Testing Chapter 9.2 Program-based Grammars
Introduction to Software Testing Chapter 5.2 Program-based Grammars
Aditya P. Mathur Purdue University Fall 2007
Sudipto Ghosh CS 406 Fall 99 November 16, 1999
Test Case Test case Describes an input Description and an expected output Description. Test case ID Section 1: Before execution Section 2: After execution.
Software Testing Syntax-based Testing.
Institute of Computing Tech.
Mutation Testing The Mutants are Coming! Copyright © 2017 – Curt Hill.
Mutation Testing Moonzoo Kim School of Computing KAIST
UNIT-4 BLACKBOX AND WHITEBOX TESTING
Mutation Testing Faults are introduced into the program by creating many versions of the program called mutants. Each mutant contains a single fault. Test.
Presentation transcript:

Mutation Testing G. Rothermel

Fault-Based Testing White-box and black-box testing techniques use coverage of code or requirements as a “proxy” for designing what we hope will be a test suite that is effective at revealing faults. Fault-based testing instead aims to detect certain classes of known faults Example: security testing for buffer overflows

Mutation Testing Fault-based testing strategy Used to evaluate test suite adequacy Measures the effectiveness of test cases Leads to creation of more effective tests

Mutation Testing Faults are introduced into the program by creating versions of the program called mutants Each mutant contains a single fault Test cases are applied to the original program and to each mutant Goal is to cause the mutants to fail, thus demonstrating the effectiveness of the test cases

Mutation Testing  Suppose that program P has been tested against a test set T and P has not failed on any test case in T. Now suppose we do the following: Changed to PP’P’ What behavior do you expect from P’ against tests in T?

Mutation Testing  P ’ is known as a mutant of P.  There might be a test t in T such that P(t)≠P’(t). In this case we say that t distinguishes P’ from P. Or, that t has killed P’.  There might be not be any test t in T such that P(t)≠P’(t). In this case we say that T is unable to distinguish P and P’. Hence P’ is considered live in the test process.

Mutation Testing  If there does not exist any test case t in the input domain of P that distinguishes P from P ’ then P ’ is said to be equivalent to P.  If P’ is not equivalent to P but no test in T is able to distinguish it from P then T is considered inadequate.  A non-equivalent and live mutant offers the tester an opportunity to generate a new test case and hence enhance T.

Mutation Testing … Original Program Mutants M1 M2 M3 Mi T1 T2 T3 T4 T5... Tj X X X killed live mutation program

Example of a Program Mutation 1 int max(int x, int y) 2 { 3 int mx = x; 4 if (x > y) 5 mx = x; 6 else 7 mx = y; 8 return mx; 9 } 1 int max(int x, int y) 2 { 3 int mx = x; 4 if (x < y) 5 mx = x; 6 else 7 mx = y; 8 return mx; 9 }

Mutation Score The mutation score for a test suite T: % of non- equivalent mutants killed by the tests in T Mutation Score = 100 *D / (N – E) D = number of killed mutants N = total number of mutants E = number of equivalent mutants Test suite T is mutation-adequate if its mutation score is 100%

Distinguishing a Mutant A test case t that distinguishes a mutant M from its parent program P must satisfy 3 conditions: Condition 1: Reachability: t must cause m to follow a path that arrives at the mutated statement in M. Condition 2: Infection: must cause the sate of M and P to differ consequent to some execution of the mutated statement. Condition 3: Propagation: must ensure that the difference in the states of M and P, created due to the execution of the mutated statement, propagates until after the end of mutant execution.

Equivalent Mutants The problem of deciding whether or not a mutant is equivalent to its parent program is undecidable. There is no way to automate detection of equivalent mutants. The number of equivalent mutants can vary from one program to another. Empirical studies have shown that one can expect about 5% of the generated mutants to be equivalent mutants. Identifying equivalent mutants is generally a manual and often time consuming---as well as frustrating--- process.

Test Adequacy using Mutation  Given a test set T for program P that must meet requirements R, a test adequacy assessment procedure proceeds as follows.  Step 1: Create a set M of mutants of P. Let M={M 1, M 2 …M k }. Note that we have k mutants.  Step 2: For each mutant M i determine whether there exists a test t in T such that M i (t)≠P(t). If such a t exists then M i is considered killed and removed from further consideration.

Test Adequacy using Mutation  Step 3: At the end of Step 2 suppose that k 1 ≤ k mutants have been killed and (k-k 1 ) mutants are live. Case 1: (k-k 1 )=0: T is adequate with respect to mutation. Case 2: (k-k 1 )>0 then we compute the mutation score (MS) as follows: MS=k 1 /(k-e) Where e is the number of equivalent mutants. Note: e ≤ (k-k 1 ).

Test Enhancement using Mutation  One has the opportunity to enhance a test set T after having assessed its adequacy.  Step 1: If the mutation score (MS) is 100%, then some other technique, or a different set of mutants, needs to be used to help enhance T.  Step 2: If the mutation score (MS) is less than 100%, then there exist live mutants that are not equivalent to P. Each live mutant needs to be distinguished from P.

Test Enhancement using Mutation  Step 3: Hence a new test t is designed with the objective of distinguishing at least one of the live mutants; let us say this is mutant m.  Step 4: If t does not distinguish m then another test t needs to be designed to distinguish m. Suppose that t does distinguish m.  Step 5: It is also possible that t also distinguishes other live mutants.

Test Enhancement using Mutation  Step 6: One now adds t to T and re-computes the mutation score (MS).  Repeat the enhancement process from Step 1.

Competent Programmer Hypothesis (CPH) CPH states that given a problem statement, a programmer writes a program P that is in the general neighborhood of the set of correct programs. An extreme interpretation of CPH is that when asked to write a program to find the account balance, given an account number, a programmer is unlikely to write a program that deposits money into an account.

A more reasonable interpretation of the CPH is that the program written to satisfy a set of requirements will be a few mutants away from a correct program. The CPH assumes that the programmer knows of an algorithm to solve the problem at hand, and if not, will find one prior to writing the program. Competent Programmer Hypothesis (CPH)

The mutants simulate the likely effect of real faults. Therefore, if the test set is good at catching the artificial mutants, it will also be good at catching the real faults in our program Competent Programmer Hypothesis (CPH)

Coupling Hypothesis If there are any large and dramatic effects that arise from bugs in the software then these will be closely coupled to small and simple bugs. The net effect of these assumptions is that we take on faith the basic principle of mutation testing: making small mutations to the program code emulates the real bugs in the software.

Mutation Operators A mutation operator O is a function that maps the program under test to a set of k (zero or more) mutants of P. O(P) M1 M2 Mk ….

Mutation Operators A mutation operator creates mutants by making simple changes in the program under test. For example, the “variable replacement” mutation operator replaces a variable name by another variable declared in the program. A “relational operator replacement” mutation operator replaces relational operator with another relational operator.

Mutation Operators: Goodness The design of mutation operators is based on guidelines and experience. It is thus evident that two groups might arrive at a different set of mutation operators for the same programming language. How should we judge whether or not that a set of mutation operators is “good enough?”

Mutation Operators: Goodness Informal definition: Let S1 and S2 denote two sets of mutation operators for language L. We say that S1 is superior to S2 if mutants generated using S1 guarantee a larger number of errors detected over a set of erroneous programs.

Mutation Operators: Goodness Generally one uses a small set of highly effective mutation operators rather than the complete set of operators. Experiments have revealed relatively small sets of mutation operators for C and Fortran. We say that one is using “constrained” or “selective” mutation when one uses this small set of mutation operators.

Mutation Operators: Language Dependence For each programming language one develops a set of mutation operators. Languages differ in their syntax thereby offering opportunities for making mistakes that duffer between two languages. This leads to differences in the set of mutation operators for two languages. Mutation operators have been developed for languages such as Fortran, C, Ada, and Java.

Mutation Operators: Examples Mutation operatorIn PIn mutant Variable replacementz=x*y+1;x=x*y+1; z=x*x+1; Relational operator replacement if (x<y)if(x>y) if(x<=y) Off-by-1z=x*y+1;z=x*(y+1)+1; z=(x+1)*y+1; Replacement by 0z=x*y+1;z=0*y+1; z=0; Arithmetic operator replacement z=x*y+1;z=x*y-1; z=x+y-1;

Experiences Theoretical and experimental results have shown that mutation testing is effective to measure adequacy of test cases The major drawbacks of mutation testing are the cost of generating the mutants and executing each test case against them, and the cost of determining equivalent mutants Mutations have also been used in experimental evaluations of testing techniques