Software by Purposefully Inserting Defects Gregory M. Kapfhammer† Department of Computer Science Allegheny College http://www.cs.allegheny.edu/∼gkapfham/ University of Delhi – May 2, 2012 †Joint with Ren´ e Just and Franz Schweiggert (University of Ulm) and Jonathan Miller Kauffman (Allegheny College)
Motivation The magic of myth and legend has come true in our time. One types the correct incantation on a keyboard, and a display screen comes to life, showing things that never were nor could be. Frederick P. Brooks, Jr. Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
Motivation The magic of myth and legend has come true in our time. One types the correct incantation on a keyboard, and a display screen comes to life, showing things that never were nor could be. Frederick P. Brooks, Jr. In reference to software! Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
Motivation I believe the hard part of building software to be the specification, design, and testing of this con- ceptual construct, not the labor of representing it and testing the fidelity of the representation. Frederick P. Brooks, Jr. Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
Motivation I believe the hard part of building software to be the specification, design, and testing of this con- ceptual construct, not the labor of representing it and testing the fidelity of the representation. Frederick P. Brooks, Jr. What happens if the “incantation” is incorrect? Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
Motivation I believe the hard part of building software to be the specification, design, and testing of this con- ceptual construct, not the labor of representing it and testing the fidelity of the representation. Frederick P. Brooks, Jr. How do we efficiently and effectively test software? Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
a Test Case? Method Under Test Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
a Test Case? Method Under Test Input Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
a Test Case? Method Under Test Input Output Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
a Test Case? Method Under Test Test Set Up Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
a Test Case? Method Under Test Test Set Up Input Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
a Test Case? Method Under Test Test Set Up Input Output Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
a Test Case? Method Under Test Test Set Up Input Output Test Clean Up Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
a Test Case? Method Under Test Test Set Up Input Output Test Clean Up Test Oracle Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
a Test Case? Method Under Test Test Set Up Input Output Test Clean Up Test Oracle Expected Output Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
a Test Case? Method Under Test Test Set Up Input Output Test Clean Up Test Oracle Expected Output Test Verdict Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
a Test Case? Method Under Test Test Set Up Input Output Test Clean Up Test Oracle Expected Output Test Verdict Expected Output Output Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
a Test Case? Method Under Test Test Set Up Input Output Test Clean Up Test Oracle Expected Output Test Verdict Expected Output Output Test Verdict The test case passes and the code is correct! Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
a Test Case? Method Under Test Test Set Up Input Output Test Clean Up Test Oracle Expected Output Test Verdict Expected Output Output Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
a Test Case? Method Under Test Test Set Up Input Output Test Clean Up Test Oracle Expected Output Test Verdict Expected Output Output Test Verdict The test case fails and a defect is found! Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
a Test Suite? T1 T2 Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
a Test Suite? T1 T2 T3 T4 Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
a Test Suite? T1 T2 T3 T4 T5 T6 Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
a Test Suite? T1 T2 T3 T4 T5 T6 T7 T8 Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
a Test Suite? T1 T2 T3 T4 T5 T6 T7 T8 T9 T10 Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
a Test Suite? T1 T2 T3 T4 T5 T6 T7 T8 T9 T10 Test Suite T = T1, T2, . . . , T9, T10 Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
a Test Suite? T1 T2 T3 T4 T5 T6 T7 T8 T9 T10 Test Suite T = T1, T2, . . . , T9, T10 R1 R2 Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
a Test Suite? T1 T2 T3 T4 T5 T6 T7 T8 T9 T10 Test Suite T = T1, T2, . . . , T9, T10 R1 R2 R3 R4 Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
a Test Suite? T1 T2 T3 T4 T5 T6 T7 T8 T9 T10 Test Suite T = T1, T2, . . . , T9, T10 R1 R2 R3 R4 R5 R6 Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
a Test Suite? T1 T2 T3 T4 T5 T6 T7 T8 T9 T10 Test Suite T = T1, T2, . . . , T9, T10 R1 R2 R3 R4 R5 R6 F1 F2 Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
a Test Suite? T1 T2 T3 T4 T5 T6 T7 T8 T9 T10 Test Suite T = T1, T2, . . . , T9, T10 R1 R2 R3 R4 R5 R6 F1 F2 F3 F4 Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
a Test Suite? T1 T2 T3 T4 T5 T6 T7 T8 T9 T10 Test Suite T = T1, T2, . . . , T9, T10 R1 R2 R3 R4 R5 R6 F1 F2 F3 F4 B1 B2 Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
a Test Suite? T1 T2 T3 T4 T5 T6 T7 T8 T9 T10 Test Suite T = T1, T2, . . . , T9, T10 R1 R2 R3 R4 R5 R6 F1 F2 F3 F4 B1 B2 Requirements R = {R1 , . . . , R6 }, Features F = {F1 , . . . , F4 }, Bug Fixes B = {B1 , B2 } How Good is Test Suite T? Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
a Test Suite? T1 T2 T3 T4 T5 T6 T7 T8 T9 T10 Test Suite T = T1, T2, . . . , T9, T10 R1 R2 R3 R4 R5 R6 F1 F2 F3 F4 B1 B2 Requirements R = {R1 , . . . , R6 }, Features F = {F1 , . . . , F4 }, Bug Fixes B = {B1 , B2 } How Good is Test Suite T? Coverage Analysis Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
a Test Suite? T1 T2 T3 T4 T5 T6 T7 T8 T9 T10 Test Suite T = T1, T2, . . . , T9, T10 R1 R2 R3 R4 R5 R6 F1 F2 F3 F4 B1 B2 Requirements R = {R1 , . . . , R6 }, Features F = {F1 , . . . , F4 }, Bug Fixes B = {B1 , B2 } How Good is Test Suite T? Coverage Analysis Mutation Analysis Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
if(a > 10) Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
if(a > 10) if(a >= 10) Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
if(a > 10) if(a >= 10) Implemented Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
if(a > 10) if(a >= 10) a true false Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
if(a > 10) if(a >= 10) a true false a true false Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
if(a > 10) if(a >= 10) a true false a true false a = 0 Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
if(a > 10) if(a >= 10) a true false a true false a = 0 false false Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
if(a > 10) if(a >= 10) a true false a true false a = 15 Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
if(a > 10) if(a >= 10) a true false a true false a = 15 true true Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
if(a > 10) if(a >= 10) a true false a true false a = 10 Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
if(a > 10) if(a >= 10) a true false a true false a = 10 false true Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
if(a > 10) if(a >= 10) a true false a true false a = 10 false true Can the tests differentiate between implemented and potential fault? Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
if(a > 10) if(a >= 10) a true false a true false a = 10 false true If yes, then the tests are adequate! Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
if(a > 10) if(a >= 10) a true false a true false a = 10 false true If no, then the tests must be improved! Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
if(a > 10) if(a >= 10) a true false a true false a = 10 false true Purposefully insert faults in order to implement quality software! Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
Mutation Analysis Mutation Operator Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
Mutation Analysis Mutation Operator Mutation Operator Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
Mutation Analysis Mutation Operator Mutation Operator Mutation Operator Mutation Operator Methodically inject small syntactical faults into the program under test Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
Mutation Analysis Mutation Operator Mutation Operator Mutation Operator Mutation Operator Methodically inject small syntactical faults into the program under test Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
Mutation Analysis Mutation Operator Mutation Operator Mutation Operator Mutation Operator Methodically inject small syntactical faults into the program under test Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
Mutation Analysis Mutation Operator Mutation Operator Mutation Operator Mutation Operator Methodically inject small syntactical faults into the program under test Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
Mutation Analysis Test Case T1 Test Case T2 Test Case T3 Test Case T4 Execute the test suite after enabling a single mutant in the program under test Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
Mutation Analysis Test Case T1 Test Case T2 Test Case T3 Test Case T4 Execute the test suite after enabling a single mutant in the program under test Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
Mutation Analysis Test Case T1 Test Case T2 Test Case T3 Test Case T4 Execute the test suite after enabling a single mutant in the program under test Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
Mutation Analysis Test Case T1 Test Case T2 Test Case T3 Test Case T4 Execute the test suite after enabling a single mutant in the program under test Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
Mutation Analysis Test Case T1 Test Case T2 Test Case T3 Test Case T4 Execute the test suite after enabling a single mutant in the program under test Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
Mutation Analysis Test Case T1 Test Case T2 Test Case T3 Test Case T4 Execute the test suite after enabling a single mutant in the program under test Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
Mutation Analysis Test Case T1 Test Case T2 Test Case T3 Test Case T4 Execute the test suite after enabling a single mutant in the program under test Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
Mutation Analysis Test Case T1 Test Case T2 Test Case T3 Test Case T4 Execute the test suite after enabling a single mutant in the program under test Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
Mutation Analysis Test Case T1 Test Case T2 Test Case T3 Test Case T4 Execute the test suite after enabling a single mutant in the program under test Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
Mutation Analysis Test Case T1 Test Case T2 Test Case T3 Test Case T4 Execute the test suite after enabling a single mutant in the program under test The test suite cannot kill the mutant – either a test suite weakness or an equivalent mutant! Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
Mutation Analysis Test Case T1 Test Case T2 Test Case T3 Test Case T4 Execute the test suite after enabling a single mutant in the program under test Repeat this process for all of the test cases and mutants – calculate mutation score when finished Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
this Presentation Efficient Mutation Analysis Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
this Presentation Efficient Mutation Analysis Challenges Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
this Presentation Efficient Mutation Analysis Challenges Solutions Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
this Presentation Efficient Mutation Analysis Challenges Solutions Conditional Mutation Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
this Presentation Efficient Mutation Analysis Challenges Solutions Conditional Mutation Syntax Tree Transformation Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
this Presentation Efficient Mutation Analysis Challenges Solutions Conditional Mutation Syntax Tree Transformation Expressions and Statements Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
this Presentation Efficient Mutation Analysis Challenges Solutions Conditional Mutation Syntax Tree Transformation Expressions and Statements Compiler Integrated Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
this Presentation Efficient Mutation Analysis Challenges Solutions Conditional Mutation Syntax Tree Transformation Expressions and Statements Compiler Integrated Comprehensive Empirical Study Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
this Presentation Efficient Mutation Analysis Challenges Solutions Conditional Mutation Syntax Tree Transformation Expressions and Statements Compiler Integrated Comprehensive Empirical Study Efficient Technique - Fully Integrated into the Java 6 SE Compiler Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
Analysis public int eval(int x){ int a=3, b=1, y; y = a * x; y += b; return y; } public int max(int a, int b){ int max = a; if(b>a){ max=b; } return max; } Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
Analysis public int eval(int x){ int a=3, b=1, y; y = a * x; y += b; return y; } public int max(int a, int b){ int max = a; if(b>a){ max=b; } return max; } Methodically inject small syntactical faults into the program under test Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
Analysis public int eval(int x){ int a=3, b=1, y; y = a * x; y += b; return y; } public int max(int a, int b){ int max = a; if(b>a){ max=b; } return max; } Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
Analysis public int eval(int x){ int a=3, b=1, y; y = a * x; y += b; return y; } public int max(int a, int b){ int max = a; if(b>a){ max=b; } return max; } =⇒ =⇒ • y = a - x; • y = a + x; • y = a / x; • if(b < a) • if(b != a) • if(b == a) Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
Analysis public int eval(int x){ int a=3, b=1, y; y = a * x; y += b; return y; } public int max(int a, int b){ int max = a; if(b>a){ max=b; } return max; } Unbiased and powerful method for assessing oracles and input values Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
Analysis public int eval(int x){ int a=3, b=1, y; y = a * x; y += b; return y; } public int max(int a, int b){ int max = a; if(b>a){ max=b; } return max; } Unbiased and powerful method for assessing oracles and input values Useful method for fault seeding during the empirical study of testing techniques Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
Challenges Mutant Generation Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
Challenges Mutant Generation Mutation Operators Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
Challenges Mutant Generation Mutation Operators Program Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
Challenges Mutant Generation Mutation Operators Program Mutants Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
Challenges Mutant Generation Mutation Operators Program Mutants Often Yields a Substantial Num- ber of Mutants Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
Challenges Mutant Generation Mutation Operators Program Mutants Often Yields a Substantial Num- ber of Mutants High Time Over- head for Generation Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
Challenges Mutant Generation Mutation Operators Program Mutants Often Yields a Substantial Num- ber of Mutants High Time Over- head for Generation Mutation Analysis Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
Challenges Mutant Generation Mutation Operators Program Mutants Often Yields a Substantial Num- ber of Mutants High Time Over- head for Generation Mutation Analysis Tests Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
Challenges Mutant Generation Mutation Operators Program Mutants Often Yields a Substantial Num- ber of Mutants High Time Over- head for Generation Mutation Analysis Tests Results Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
Challenges Mutant Generation Mutation Operators Program Mutants Often Yields a Substantial Num- ber of Mutants High Time Over- head for Generation Mutation Analysis Tests Results Individually Executing the Mutants is Too Expensive Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
Challenges Mutant Generation Mutation Operators Program Mutants Often Yields a Substantial Num- ber of Mutants High Time Over- head for Generation Mutation Analysis Tests Results Individually Executing the Mutants is Too Expensive Prior Solutions? Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
in Mutation Analysis Improving Mutation Analysis Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
in Mutation Analysis Improving Mutation Analysis Offutt and Untch Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
in Mutation Analysis Improving Mutation Analysis Offutt and Untch Do Fewer Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
in Mutation Analysis Improving Mutation Analysis Offutt and Untch Do Fewer Sampling Selection Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
in Mutation Analysis Improving Mutation Analysis Offutt and Untch Do Fewer Do Smarter Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
in Mutation Analysis Improving Mutation Analysis Offutt and Untch Do Fewer Do Smarter Distributed Weak Mutation Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
in Mutation Analysis Improving Mutation Analysis Offutt and Untch Do Fewer Do Smarter Do Faster Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
in Mutation Analysis Improving Mutation Analysis Offutt and Untch Do Fewer Do Smarter Do Faster Compiler Integrated Bytecode Transformation Mutant Schemata Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
in Mutation Analysis Improving Mutation Analysis Offutt and Untch Do Fewer Do Smarter Do Faster Higher Order Mutation Jia and Harman Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
Conditional Mutation Conditional Mutation Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
Conditional Mutation Conditional Mutation Encapsulates all mutants within the same block Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
Conditional Mutation Conditional Mutation Encapsulates all mutants within the same block Can be inte- grated within the compiler Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
Conditional Mutation Conditional Mutation Encapsulates all mutants within the same block Transforms the abstract syntax tree (AST) Can be inte- grated within the compiler Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
Conditional Mutation Conditional Mutation Encapsulates all mutants within the same block Transforms the abstract syntax tree (AST) Stmt → Conditional Stmt (if-then-else, switch) Expr → Conditional Expr (conditional operator ?:) Can be inte- grated within the compiler Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
Transforming the AST public int eval(int x){ int a=3, b=1, y; y = a * x ; y += b; return y; } Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
Transforming the AST public int eval(int x){ int a=3, b=1, y; y = a * x ; y += b; return y; } ⇓ ASSIGN IDENT y BINARY ∗ a x Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
Transforming the AST public int eval(int x){ int a=3, b=1, y; y = a * x ; y += b; return y; } ⇓ ASSIGN IDENT y BINARY ∗ a x Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
Transforming the AST public int eval(int x){ int a=3, b=1, y; y = a * x ; y += b; return y; } ⇓ ASSIGN IDENT y BINARY ∗ a x =⇒ =⇒ ASSIGN IDENT y COND-EXPR THEN BINARY + a x COND (M NO ==2) ELSE COND-EXPR THEN BINARY - a x COND (M NO ==1) ELSE BINARY ∗ a x Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
Source Code View of Inserting Mutants public int eval(int x){ int a=3, b=1, y; y = a * x ; y += b; return y; } 1 Define mutation operators MOP(x ∗ y) = {x − y, x + y, x/y} 2 Determine whether current expression or statement is affected by mutation 3 Apply mutation operators Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
Source Code View of Inserting Mutants public int eval(int x){ int a=3, b=1, y; y = a * x ; y += b; return y; } 1 Define mutation operators MOP(x ∗ y) = {x − y, x + y, x/y} 2 Determine whether current expression or statement is affected by mutation 3 Apply mutation operators Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
Source Code View of Inserting Mutants public int eval(int x){ int a=3, b=1, y; y = a * x ; y += b; return y; } 1 Define mutation operators MOP(x ∗ y) = {x − y, x + y, x/y} 2 Determine whether current expression or statement is affected by mutation 3 Apply mutation operators Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
Source Code View of Inserting Mutants public int eval(int x){ int a=3, b=1, y; y = (M_NO==1)? a - x : a * x ; y += b; return y; } 1 Define mutation operators MOP(x ∗ y) = {x − y, x + y, x/y} 2 Determine whether current expression or statement is affected by mutation 3 Apply mutation operators Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
Source Code View of Inserting Mutants public int eval(int x){ int a=3, b=1, y; y = (M_NO==2)? a + x : (M_NO==1)? a - x : a * x ; y += b; return y; } 1 Define mutation operators MOP(x ∗ y) = {x − y, x + y, x/y} 2 Determine whether current expression or statement is affected by mutation 3 Apply mutation operators Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
Source Code View of Inserting Mutants public int eval(int x){ int a=3, b=1, y; y = (M_NO==3)? a / x : (M_NO==2)? a + x : (M_NO==1)? a - x : a * x ; y += b; return y; } 1 Define mutation operators MOP(x ∗ y) = {x − y, x + y, x/y} 2 Determine whether current expression or statement is affected by mutation 3 Apply mutation operators Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
Source Code View of Inserting Mutants public int eval(int x){ int a=3, b=1, y; y = (M_NO==3)? a / x : (M_NO==2)? a + x : (M_NO==1)? a - x : a * x ; y += b; return y; } Mutants that are not ex- ecuted cannot be killed 1 Define mutation operators MOP(x ∗ y) = {x − y, x + y, x/y} 2 Determine whether current expression or statement is affected by mutation 3 Apply mutation operators Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
Collecting and Using Mutation Coverage public int eval(int x){ int a=3, b=1, y; y = (M_NO==3)? a / x : (M_NO==2)? a + x : (M_NO==1)? a - x : a * x ; y += b; return y; } Mutants that are not ex- ecuted cannot be killed Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
Collecting and Using Mutation Coverage public int eval(int x){ int a=3, b=1, y; y = (M_NO==3)? a / x : (M_NO==2)? a + x : (M_NO==1)? a - x : (M_NO==0 && COVERED(1,3))? a * x : a * x ; y += b; return y; } Mutants that are not ex- ecuted cannot be killed Determine covered mutants with addi- tional instrumentation Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
Collecting and Using Mutation Coverage public int eval(int x){ int a=3, b=1, y; y = (M_NO==3)? a / x : (M_NO==2)? a + x : (M_NO==1)? a - x : (M_NO==0 && COVERED(1,3))? a * x : a * x ; y += b; return y; } Mutants that are not ex- ecuted cannot be killed Determine covered mutants with addi- tional instrumentation Only execute and investi- gate the covered mutants Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
MAJOR’s Compiler MAJOR’s Compiler Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
MAJOR’s Compiler MAJOR’s Compiler Enhanced the Standard Java Compiler Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
MAJOR’s Compiler MAJOR’s Compiler Enhanced the Standard Java Compiler Source Files Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
MAJOR’s Compiler MAJOR’s Compiler Enhanced the Standard Java Compiler Source Files Common Compiler Options Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
MAJOR’s Compiler MAJOR’s Compiler Enhanced the Standard Java Compiler Source Files Common Compiler Options Domain Specific Language Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
MAJOR’s Compiler MAJOR’s Compiler Enhanced the Standard Java Compiler Source Files Common Compiler Options Domain Specific Language Bytecode with Embedded Mutants Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
Integration into the Java Compiler Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
Integration into the Java Compiler Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
Integration into the Java Compiler Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
Integration into the Java Compiler Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
Optimized Mutation Analysis Process 1 Embed and compile all mutants 2 Run test suite on instrumented program 3 Sort tests according to their runtime 4 Perform mutation analysis with reordered test suite Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
Optimized Mutation Analysis Process 1 Embed and compile all mutants 2 Run test suite on instrumented program 3 Sort tests according to their runtime 4 Perform mutation analysis with reordered test suite Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
Optimized Mutation Analysis Process 1 Embed and compile all mutants 2 Run test suite on instrumented program 3 Sort tests according to their runtime 4 Perform mutation analysis with reordered test suite Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
Optimized Mutation Analysis Process 1 Embed and compile all mutants 2 Run test suite on instrumented program 3 Sort tests according to their runtime 4 Perform mutation analysis with reordered test suite Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
and Compilation 1 2 3 4 5 6 7 8 9 10 11 12 0 20000 40000 60000 80000 100000 120000 140000 Compiler runtime in seconds Number of mutants apache ant jfreechart itext java pathfinder commons math commons lang numerics4j Overhead for generating and compiling mutants is negligible Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
and Compilation 1 2 3 4 5 6 7 8 9 10 11 12 0 20000 40000 60000 80000 100000 120000 140000 Compiler runtime in seconds Number of mutants apache ant jfreechart itext java pathfinder commons math commons lang numerics4j Overhead for generating and compiling mutants is negligible Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
and Improving Mutation Analysis 0 20 40 60 80 100 120 140 160 180 0 20 40 60 80 100 Number of killed mutants Runtime in seconds optimized order (using coverage information) random order (using coverage information) original order (using coverage information) optimized order (without coverage information) random order (without coverage information) original order (without coverage information) • Mutation analysis is not feasible without coverage information • Reordering the test suite significantly speeds up the process, especially if runtimes of tests differ by orders of magnitude Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
and Improving Mutation Analysis 0 20 40 60 80 100 120 140 160 180 0 20 40 60 80 100 Number of killed mutants Runtime in seconds optimized order (using coverage information) random order (using coverage information) original order (using coverage information) optimized order (without coverage information) random order (without coverage information) original order (without coverage information) • Mutation analysis is not feasible without coverage information • Reordering the test suite significantly speeds up the process, especially if runtimes of tests differ by orders of magnitude Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
and Improving Mutation Analysis 0 20 40 60 80 100 120 140 160 180 0 20 40 60 80 100 Number of killed mutants Runtime in seconds optimized order (using coverage information) random order (using coverage information) original order (using coverage information) optimized order (without coverage information) random order (without coverage information) original order (without coverage information) • Mutation analysis is not feasible without coverage information • Reordering the test suite significantly speeds up the process, especially if runtimes of tests differ by orders of magnitude Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
Quality Mutation Analysis Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
Quality Mutation Analysis Program Test Suite Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
Quality Mutation Analysis Program Test Suite Mutation Score Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
Quality Mutation Analysis Program Test Suite Mutation Score Improve Tests Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
Quality Mutation Analysis Program Test Suite Mutation Score Improve Tests Automated Manual Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
Quality Mutation Analysis Program Test Suite Mutation Score Improve Tests Use Tests Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
Quality Mutation Analysis Program Test Suite Mutation Score Improve Tests Use Tests Test improvement is only effective if mutation analysis is efficient! Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
Mutation Analysis Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
Mutation Analysis Efficiency: MAJOR has ac- ceptable time and space over- heads and scales to large, real-world programs Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
Mutation Analysis Efficiency: MAJOR has ac- ceptable time and space over- heads and scales to large, real-world programs Usability: MAJOR’s inte- gration into the Java SE compiler makes it a no- hassle, drop-in tool Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
Mutation Analysis Efficiency: MAJOR has ac- ceptable time and space over- heads and scales to large, real-world programs Usability: MAJOR’s inte- gration into the Java SE compiler makes it a no- hassle, drop-in tool We will release MAJOR as free and open source software Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
Conclusion Key Concepts and Features: • Compiler-integrated solution • Conditional mutation with the abstract syntax tree • Furnishes its own domain specific language • Collects and leverages mutation coverage information Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
Conclusion Key Concepts and Features: • Compiler-integrated solution • Conditional mutation with the abstract syntax tree • Furnishes its own domain specific language • Collects and leverages mutation coverage information Characteristics of MAJOR: • Fast and scalable technique • Configurable and extensible mutation tool • Enables an optimized workflow for mutation analysis Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
Recently Published Papers • Ren´ e Just, Gregory M. Kapfhammer, and Franz Schweiggert. Using conditional mutation to increase the efficiency of mutation analysis. In Proceedings of the 6th International Workshop on the Automation of Software Test, Honolulu, Hawaii, May 2011. • Ren´ e Just, Franz Schweiggert, and Gregory M. Kapfhammer. MAJOR: An efficient and extensible tool for mutation analysis in a Java compiler. In Proceedings of the 26th IEEE/ACM International Conference on Automated Software Engineering (Tool Paper), Lawrence, Kansas, November 2011. Kapfhammer Allegheny College Efficient and Effective Mutation Testing: Supporting the Implementation of Quality Software by Purposefully Inserting Defects
Software by Purposefully Inserting Defects Gregory M. Kapfhammer Department of Computer Science Allegheny College http://www.cs.allegheny.edu/∼gkapfham/ Thank you for your attention! I welcome your questions and comments.