Mutation Testing. Mutation testing is a fault-based testing technique. It has been empirically and theoretically validated that a program will be well.

Slides:



Advertisements
Similar presentations
Decision Making EE2372 Software Design I Dr. Gerardo Rosiles.
Advertisements

Templates in C++. Generic Programming Programming/developing algorithms with the abstraction of types The uses of the abstract type define the necessary.
Type checking © Marcelo d’Amorim 2010.
5th MaCS Debrecen On the Turing-Completeness of Generative Metaprograms Zoltán Porkoláb, István Zólyomi Dept. of Programming.
An Analysis and Survey of the Development of Mutation Testing by Yue Jia and Mark Harmon A Quick Summary For SWE6673.
Conditional statements and Boolean expressions. The if-statement in Java (1) The if-statement is a conditional statement The statement is executed only.
Lecture 7 Advanced Topics in Testing. Mutation Testing Mutation testing concerns evaluating test suites for their inherent quality, i.e. ability to reveal.
Mutation Testing Presented by Sharath Kumar Garlapati Vinesh Thummala.
1 Software Testing and Quality Assurance Lecture 9 - Software Testing Techniques.
ISBN Chapter 7 Expressions and Assignment Statements.
1 Chapter 4 Language Fundamentals. 2 Identifiers Program parts such as packages, classes, and class members have names, which are formally known as identifiers.
Introduction and Syntax. Course objectives Discuss features of programming languages. Discuss how the features are implemented in a simple computer architecture.
Chapter 7 Expressions and Assignment Statements. Copyright © 2007 Addison-Wesley. All rights reserved. 1–2 Arithmetic Expressions Arithmetic evaluation.
Debugging and Injecting Course Software Testing & Verification 2014/15 Wishnu Prasetya The debugging part uses Andreas Zeller’s slides. This is extra.
Language Evaluation Criteria
Introduction to Software Testing Chapter 5.2 Program-based Grammars Paul Ammann & Jeff Offutt
Software Testing and Validation SWE 434
1-1 University of Hail College of Computer Science and Engineering Department of computer Science and Software Engineering Course: ICS313: Fundamentals.
Ryan Chu. Arithmetic Expressions Arithmetic expressions consist of operators, operands, parentheses, and function calls. The purpose is to specify an.
Chapter 7 Expressions and Assignment Statements. Copyright © 2007 Addison-Wesley. All rights reserved. 1–2 Arithmetic Expressions Arithmetic evaluation.
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.
C++ Template Metaprogramming Why, When and How? Zoltán Porkoláb Dept. of Programming Languages and Compilers, Faculty of Informatics Eötvös.
 Java has the logical operators and, or, and not, symbolized by &&, ||, and !, respectively.  Logical or means one or the other or both conditions hold.
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.
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.
Introduction to Software Testing Chapter 9.3 Integration and Object- Oriented Testing Paul Ammann & Jeff Offutt
Syntax-Based Testing Mingzhe Du Hongying Du Dharani Chintapatla.
Introduction to Software Testing Chapter 5.3 Integration and Object-Oriented Testing Paul Ammann & Jeff Offutt
Fault Generation Tool (FGT) of Error-Space Model (ESM) for the generation of test cases and estimation of software reliability Hong Zhang May 06, 2003.
Arithmetic Expressions
These notes were originally developed for CpSc 210 (C version) by Dr. Mike Westall in the Department of Computer Science at Clemson.
Expressions and Assignment Statements
Chapter 7 Expressions and Assignment Statements. Outline Introduction Arithmetic Expressions Overloaded Operators Type Conversions Assignment Statements.
Software Testing Integration and Object-Oriented Testing.
1 Original Source : and Problem and Problem Solving.ppt.
1 Type Sensitive Application of Mutation Operators for Dynamically Typed Programs Leonardo Bottaci Department of Computer Science University of Hull, Hull,
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.
Introduction to Software Testing Chapter 5.3 Integration and Object-Oriented Testing Paul Ammann & Jeff Offutt
Introduction to Software Testing Chapter 5.3 Integration and Object-Oriented Testing Paul Ammann & Jeff Offutt
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
Polymorphism CMPS Poly-morphism Means “many-forms” Means different things in biology, chemistry, computer science Means different things to functional.
How to execute Program structure Variables name, keywords, binding, scope, lifetime Data types – type system – primitives, strings, arrays, hashes – pointers/references.
Mutation Testing Breaking the application to test it.
MUTACINIS TESTAVIMAS Benediktas Knispelis, IFM-2/2 Mutation testing.
Mutation Testing Laraib Zahid & Mariam Arshad. What is Mutation Testing?  Fault-based Testing: directed towards “typical” faults that could occur in.
Software Testing and Quality Assurance Syntax-Based Testing (2) 1.
Rational Expressions relational operators logical operators order of precedence.
5th MaCS Debrecen On the Turing-Completeness of Generative Metaprograms Zoltán Porkoláb, István Zólyomi Dept. of Programming.
C++ LANGUAGE MULTIPLE CHOICE QUESTION
PROGRAMMING LANGUAGES
Operators in c++.
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.
Types of Programming Languages
Introduction to Software Testing Chapter 9.2 Program-based Grammars
Introduction to Software Testing Chapter 5.2 Program-based Grammars
An Empirical Evaluation of the MuJava Mutation Operators
Software Testing Syntax-based Testing.
Mutation Testing The Mutants are Coming! Copyright © 2017 – Curt Hill.
Chapter 7 Expressions and Assignment Statements.
Mutation Testing Moonzoo Kim School of Computing KAIST
B=15 b = a + fun(a); a=10 fun(a)=5.
An Analysis of OO Mutation Operators Jingyu Hu, Nan Li, and Jeff Offutt Presented by Nan Li 03/24/2011.
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

Mutation testing is a fault-based testing technique. It has been empirically and theoretically validated that a program will be well tested if most simple faults are detected and removed.

Mutants Mutation testing generates a set of faulty versions of the original program. Each version, called a mutant, contains a single fault. A fault is introduced into the original program by a single syntactic change to a program statement.

An Example 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 Analysis Process A set of test cases are first applied to the original program to detect and fix the faults in the program. Test cases are then applied to the mutants. A mutant is killed by a test case if it generates a different output from the original program. A test case is adequate if it kills at least one mutant.

Equivalent Mutants Two programs are functionally equivalent if they always produce the same output on every input. If a mutant is functionally equivalent to the original program, then it cannot be killed by the set of test cases.

Mutation Score A mutation score of a set of test cases is the percentage of non-equivalent mutants that are killed by the set of test cases. If a program P has M mutants, E of which are equivalent, and a set of test cases T kills K mutants, then the mutation score is defined as K MS(P, T) =. M - E

Measuring Adequacy of Test Cases Mutation analysis is a way to measure the adequacy of a set of test cases. A set of test cases is mutation adequate if its mutation score is 100%. In practice, it is difficult to have a set of test cases that has mutation score above 95%.

Mutation Operators A mutation operator is a syntactic change to a program to create mutant. The set of mutation operators depends on the programming language. Mothra is a mutation testing system for Fortran 77 that supports 22 mutation operators.

Mutation Operators in Mothra AAR: array reference for array reference replacement ABS: absolute value insertion ACR: array reference for constant replacement AOR: arithmetic operator replacement ASR: array reference for scalar variable replacement

Mutation Operators in Mothra CAR: constant for array reference replacement CNR: comparable array name replacement CRP: constant replacement CSR constant for scalar variable replacement DER: DO statement end replacement DSA: DATA statement alternations GLR: GOTO label replacement

Mutation Operators in Mothra LCR: logical connector replacement ROR: relational operator replacement RSR: RETURN statement replacement SAN: statement analysis SAR: scalar variable for array reference replacement SCR: scalar for constant replacement SDL: statement deletion

Mutation Operators in Mothra SRC: source constant replacement SVR: scalar variable replacement UOI: unary operator insertion

High Cost of Mutation Testing The main drawback of mutation testing is the high cost of running vast number of mutants against the set of test cases. The number of mutants generated for a program is proportional to the product of the number of data references and the number of data objects. This number is large for even small programs.

Reducing Cost of Mutation Testing Selective mutation: a “do fewer approach”. Weak mutation: a “do smarter approach”. Schema-based mutation analysis: a “do faster approach”. MuJava is a mutation testing system for Java that implements these three approaches. MuClipse is an Eclipse plugin for MuJava.

Selective Mutation Selective mutations are mutations that omit the operators that create the most mutants. A N-selective mutation omits the N most prevalent operators. For example, a 2-selective mutation for Mothra will omit the SVR and ASR operators.

Distribution of Mutation Operators

Categories of Mutation Operators Replacement of Operand operators: replace each operand in a program with each other legal operand. (AAR, ACR, ASR, CAR, CNR, CRP, CSR, SAR, SCR, SRC, and SVR) Expression Modification operators: modify expressions by replacing operators or inserting new operators. (ABS, AOR, LCR, ROR, and UOI) Statement Modification operators: modify entire statements. (DER, DSA, GLR, RSR, SAN, and SDL)

Coverage and Saving Mutation ScorePercentage Saved ES RS RE E

Summary Experiments show that 5 key mutation operators ABS, AOR, LCR, ROR, and UOI provide almost the same coverage as the 22 mutation operators in Mothra. The cost reductions are at least 4 times for small programs and up to 50 times for large programs.

Method Level Mutation Operators in MuClipse AOR: Arithmetic operator replacement (+, -, *, /, %, +, -, ++, --) AOI: Arithmetic operator insertion (+, -, ++, --) AOD: Arithmetic operator deletion (+, -, ++, --) ROR: Relational operator replacement (>, >=, <, <=, ==, !=)

Method Level Mutation Operators in MuClipse COR: Conditional operator replacement (&&, ||, !) COI: Conditional operator insertion (!) COD: Conditional operator deletion (!) SOR: Shift operator replacement ( >, >>>)

Method Level Mutation Operators in MuClipse LOR: Logical operator replacement (&, |, ^) LOI: Logical operator insertion (~) LOD: Logical operator deletion (~) ASR: Assignment operator replacement (+=, -=, *=, /=, %=, &=, |=, ^=, >=, >>>=)

Weak Mutation Weak mutation is an approximation technique that compares the internal states of the mutant and the original program immediately after the execution of the mutated portion of the program. Experiments show that weak mutation is almost as effective as strong mutation. The cost reductions are at least 50%.

Four Potential Points for State Comparisons After the first evaluation of the innermost expression surrounding the mutated symbol. After the first evaluation of the mutated statement. After the first evaluation of the basic block that contains the mutated statement. After each evaluation of the basic block that contains the mutated statement. best

Schema-Based Mutation Analysis The schema-based mutation analysis encodes all mutants into a specially parameterized source-level program, called a metamutant. The metamutant is compiled using the same compiler used to compile the original program. The metamutant has the ability to function as any of the mutant at runtime. Cost reductions can be an order of magnitude.

Metaoperators Consider the AOR mutation operator. For the statement, Result = A – B, four mutants are yielded: Result = A + B Result = A * B Result = A / B Result = A % B These four mutants can be generically represented as Result = A ArithOp B, where ArithOp is a metaoperator.

Metaprocedures The generic representation can be rewritten as Result = AOrr(A, B), where AOrr function performs one of the five possible arithmetic operations. AOrr is an example of a metaprocedure.

Class Level Mutation Operators in MuClipse Access control: AMC Inheritance: IHD, IHI, IOD, IOP, IOR, ISK, IPC Polymorphism: PNC, PMD, PPD, PRV Overloading: OMR, OMD, OAO, OAN Java-specific features: JTD, JSC, JID, JDC Common-programming mistakes: EOA, EOC, EAM, EMM