Software Testing and Validation SWE 434

Slides:



Advertisements
Similar presentations
1 Software Unit Test Coverage And Test Adequacy Hong Zhu, Patrick A. V. Hall, John H.R. May Presented By: Arpita Gandhi.
Advertisements

White-Box Testing Techniques IV
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.
Chapter 7 User-Defined Methods. Chapter Objectives  Understand how methods are used in Java programming  Learn about standard (predefined) methods and.
(c) 2007 Mauro Pezzè & Michal Young Ch 9, slide 1 Test Case Selection and Adequacy Criteria.
(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.
(c) 2007 Mauro Pezzè & Michal Young Ch 13, slide 1 Data flow testing.
Introduction to Software Testing Chapter 9.2 Challenges in Testing Software – Software Testability Paul Ammann & Jeff Offutt
Mutant Subsumption Graphs Mutation 2014 March 31, 2014 Bob Kurtz, Paul Ammann, Marcio Delamaro, Jeff Offutt, Lin Deng.
Software Testing and QA Theory and Practice (Chapter 3: Unit Testing) © Naik & Tripathy 1 Software Testing and Quality Assurance Theory and Practice Chapter.
1 Software Testing and Quality Assurance Lecture 9 - Software Testing Techniques.
Background on Testing and Maintenance CISC 879 Fall 2008.
(c) 2007 Mauro Pezzè & Michal Young Ch 16, slide 1 Fault-Based Testing.
(c) 2007 Mauro Pezzè & Michal Young Ch 1, slide 1 Software Test and Analysis in a Nutshell.
(c) 2007 Mauro Pezzè & Michal Young Ch 2, slide 1 A Framework for Testing and Analysis.
Software Testing and validation SQA - SWE 434
1CMSC 345, Version 4/04 Verification and Validation Reference: Software Engineering, Ian Sommerville, 6th edition, Chapter 19.
Topics in Software Dynamic White-box Testing: Data-flow Testing
Introduction to Software Testing Chapter 5.2 Program-based Grammars Paul Ammann & Jeff Offutt
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.
Foundations of Software Testing Chapter 5: Test Selection, Minimization, and Prioritization for Regression Testing Last update: September 3, 2007 These.
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.
(c) 2007 Mauro Pezzè & Michal Young The Big Picture.
Software testing techniques Software testing techniques Mutation testing Presentation on the seminar Kaunas University of Technology.
Ins & Outs of Unit Testing All About Unit Testing.
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.
637 – Introduction (Ch 1) Introduction to Software Testing Chapter 1 Jeff Offutt Information & Software Engineering SWE 437 Software Testing
1 Test Selection for Result Inspection via Mining Predicate Rules Wujie Zheng
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.
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
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,
Mutation Testing Breaking the application to test it.
Software Testing Sudipto Ghosh CS 406 Fall 99 November 23, 1999.
Week 6 MondayTuesdayWednesdayThursdayFriday Testing III Reading due Group meetings Testing IVSection ZFR due ZFR demos Progress report due Readings out.
Foundations of Software Testing Chapter 7: Test Adequacy Measurement and Enhancement Using Mutation Last update: September 3, 2007 These slides are copyrighted.
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 AND QUALITY ASSURANCE. Software Testing.
Test Case Purification for Improving Fault Localization presented by Taehoon Kwak SoftWare Testing & Verification Group Jifeng Xuan, Martin Monperrus [FSE’14]
Software Testing and Quality Assurance Practical Considerations (1) 1.
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
Handouts Software Testing and Quality Assurance Theory and Practice Chapter 3 Unit Testing
White-Box Testing Techniques IV
White-Box Testing Techniques IV
Introduction to Software Testing Chapter 9.2 Program-based Grammars
Mutation Testing Moonzoo Kim School of Computing KAIST
Analyzing the Validity of Selective Mutation with Dominator Mutants
Mutation testing Julius Purvinis IFM-0/2.
Introduction to Software Testing Chapter 9.2 Program-based Grammars
Paul Ammann & Jeff Offutt
Improving Test Suites for Efficient Fault Localization
Software Engineering Experimentation
Introduction to Software Testing Chapter 5.2 Program-based Grammars
Test Case Purification for Improving Fault Localization
Aditya P. Mathur Purdue University Fall 2007
Software Testing Syntax-based Testing.
Mutation Testing The Mutants are Coming! Copyright © 2017 – Curt Hill.
Mutation Testing Moonzoo Kim School of Computing KAIST
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:

Software Testing and Validation SWE 434 Mutation testing

Dynamic Testing Selection of test data is broadly based on the following techniques: Functional program testing Control flow testing Data flow testing Questions: How to assess the effectiveness of the test suite ? How many bugs are remaining ?

Mutation testing Create a number of mutants, i.e., faulty versions of program Each mutant contains one fault Fault created by using mutant operators Run test on the mutants (random or selected) When a test case reveals a fault, save test case and remove mutant from the set, i.e., it is killed Continue until all mutants are killed Results in a set of test cases with high quality Need for automation

Mutation Testing Modify a program by introducing a single small change to the code A modified program is called mutant A mutant is said to be killed when the execution of test case cause it to fail. The mutant is considered to be dead Given a mutant m  M for a ground string program P and a test t, t is said to kill m if and only if the output of t on P is different from the output of t on m.

Mutation Testing Mutants int getMax(int x, int y) { int getMax(int x, int y) { int max; int max; if (x >y) if (x >=y) max = x; max = x; else else max = y; max = y; return max; return max; } } int getMax(int x, int y) { int max; if (x >y) max = x; else return max; }

Examples of Mutant Operators In program In mutant Variable replacement z=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-1 z=x*(y+1)+1; z=(x+1)*y+1; Replacement by 0 z=0*y+1; z=0; Arithmetic operator replacement z=x*y-1; z=x+y-1;

Mutation Testing A mutant is an equivalent tot the given program if it always produce the same output as the original program A mutant is called killable or stubborn, if the existing set of test cases is insufficient to kill it A mutation score for a set of test cases is the percentage of non-equivalent mutants killed by the test suite The test suite is said to be mutation-adequate if its mutation score is 100%

How mutants survive A mutant may be equivalent to the original program Maybe changing (x < 0) to (x <= 0) didn’t change the output at all! The seeded “fault” is not really a “fault”. Determining whether a mutant is equivalent may be easy or hard; in the worst case it is undecideable Or the test suite could be inadequate If the mutant could have been killed, but was not, it indicates a weakness in the test suite But adding a test case for just this mutant is a bad idea. We care about the real bugs, not the fakes! (c) 2007 Mauro Pezzè & Michal Young

Mutation Testing: an example Consider the following program P: main(argc,argv) int argc, r, i; char *argv[]; { r = 1; for i = 2 to 3 do if (atoi(argv[i-1]) > atoi(argv[r-1])) r = i; printf(“Value of the rank is %d \n”, r); exit(0); } Test Case 1: input: 1 2 3 output: Value of the rank is 3 Test Case 2: input: 1 2 1 output: Values of the rank is 2 Test Case 3: input: 3 1 2 output: Value of the rank is 1

Mutation Testing: an example Test cases for the program P: Test Case 1: input: 1 2 3 output: Value of the rank is 3 Test Case 2: input: 1 2 1 output: Values of the rank is 2 Test Case 3: input: 3 1 2 output: Value of the rank is 1

Mutation Testing: an example Mutant 1: main(argc,argv) int argc, r, i; char *argv[]; { r = 1; for i = 1 to 3 do if (atoi(argv[i-1]) > atoi(argv[r-1])) r = i; printf(“Value of the rank is %d \n”, r); exit(0); } Test Case 1: input: 1 2 3 output: Value of the rank is ? Test Case 2: input: 1 2 1 output: Values of the rank is ? Test Case 3: input: 3 1 2

Mutation Testing: an example Mutant 2: main(argc,argv) int argc, r, i; char *argv[]; { r = 1; for i = 2 to 3 do if (i-1) > atoi(argv[r-1])) r = i; printf(“Value of the rank is %d \n”, r); exit(0); } Test Case 1: input: 1 2 3 output: Value of the rank is ? Test Case 2: input: 1 2 1 output: Values of the rank is ? Test Case 3: input: 3 1 2

Mutation Testing: an example Mutant 3: main(argc,argv) int argc, r, i; char *argv[]; { r = 1; for i = 2 to 3 do if (atoi(argv[i-1]) >= atoi(argv[r-1])) r = i; printf(“Value of the rank is %d \n”, r); exit(0); } Test Case 1: input: 1 2 3 output: Value of the rank is ? Test Case 2: input: 1 2 1 output: Values of the rank is ? Test Case 3: input: 3 1 2

Mutation Testing: an example main(argc,argv) int argc, r, i; char *argv[]; { r = 1; for i = 2 to 3 do if (atoi(argv[r-1]) > atoi(argv[r-1])) r = i; printf(“Value of the rank is %d \n”, r); exit(0); } Test Case 1: input: 1 2 3 output: Value of the rank is ? Test Case 2: input: 1 2 1 output: Values of the rank is ? Test Case 3: input: 3 1 2

Mutation Testing: an example Summary: After Execution of modified programs against the test suite, you will get the results: Mutants 1 & 3: Programs will pass the test suite, i.e., mutants 1 & 3 are not killable Mutant 2: Program will fail test cases 2 Mutant 4: Program will fail test case 1 and test cases 2 Mutation score is 50%, assuming mutants 1 & 3 non-equivalent

Mutation Testing: an example Improvements: The score is found to be low because we assumed mutants 1 & 3 are nonequivalent We need to show that mutants 1 and 3 are equivalent mutants or those are killable To show that those are killable, we need to add new test cases to kill these two mutants

Mutation Testing: an example Improvements: First, let us analyze mutant 1 in order to derive a “killer” test. The difference between P and mutant 1 is the starting point Mutant 1 starts with i = 1, whereas P starts with i = 2. There is no impact on the result r. Therefore, we conclude that mutant 1 is an equivalent mutant Second, if we add a fourth test case as follows: Test Case 4: input: 2 2 1 Program P will produce the output “Value of the rank is 1” and mutant 3 will produce the output “Value of the rank is 2” Thus, this test data kills mutant 3, which give us a mutation score 100%

Mutation Testing: an example Recap: Test Case 1: input: 1 2 3 output: Value of the rank is 3 Test Case 2: input: 1 2 1 output: Values of the rank is 2 Test Case 3: input: 3 1 2 output: Value of the rank is 1 Test Case 4: input: 2 2 1 which give us a mutation score 100% !!!

The Mutation Process Process Mutation Tests New Test Data If process is not error-free, fix it Create Mutants Test Process Mutation Tests New Test Data Problem with Tests? Test Mutants Any Live Mutants? Yes Any Mutations that are caught by tests are killed Test Complete No

Mutation testing Fault Forecasting

Fault Forecasting How to determine number of remaining bugs? Definition: Fault forecasting is conducted by performing an evaluation of the system behavior with respect to fault occurrence or activation Fault Injection technique: The idea is to inject (seed) some faults in the program and calculate the remaining bugs based on detecting the seeded faults [Mills 1972]. Assuming that the probability of detecting the seeded and nonseeded faults are the same.

Fault Forecasting Nr Ns Nd ns nd

Fault Forecasting Example

Mutation testing Tools

Tools for mutation testing As with any other type of test adequacy assessment, mutation based assessment must be done with the help of a tool. There are few mutation testing tools available freely. Two such tools are Proteum for C from Professor Maldonado and muJava for Java from Professor Jeff Offutt. We are not aware of any commercially available tool for mutation testing. See the textbook (Aditya) for a more complete listing of mutation tools. © Aditya P. Mathur 2009

Q & A