© SERG Dependable Software Systems (Mutation) Dependable Software Systems Topics in Mutation Testing and Program Perturbation Material drawn from [Offutt.

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

Sufficient Mutant Operators Offutt, Rothermel, Lee, Untch, and Zapf TOSEM, April 1996 Slide text copyright Robert W. Hasker, 2006 Material (and figures)
Mutation Testing Tim Dakeyne. What is Mutation? Where data is changed a small amount, which may or may not change its function Evolution of life Languages.
Mutation Testing. Mutation testing is a fault-based testing technique. It has been empirically and theoretically validated that a program will be well.
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.
An Analysis and Survey of the Development of Mutation Testing by Yue Jia and Mark Harmon A Quick Summary For SWE6673.
© SERG Dependable Software Systems (Slicing) Dependable Software Systems Topics in Program Slicing Material drawn from [Weiser84,Gallagher91,DeMillo96]
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 and Quality Assurance
Parameterizing Random Test Data According to Equivalence Classes Chris Murphy, Gail Kaiser, Marta Arias Columbia University.
Testing an individual module
1 Software Testing and Quality Assurance Lecture 5 - Software Testing Techniques.
1 Software Testing Techniques CIS 375 Bruce R. Maxim UM-Dearborn.
State coverage: an empirical analysis based on a user study Dries Vanoverberghe, Emma Eyckmans, and Frank Piessens.
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.
Introduction to Software Testing
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.
Chapter 13: Regression Testing Omar Meqdadi SE 3860 Lecture 13 Department of Computer Science and Software Engineering University of Wisconsin-Platteville.
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.
Software Reliability in Nuclear Systems Arsen Papisyan Anthony Gwyn.
White-box Testing.
CS Data Structures I Chapter 2 Principles of Programming & Software Engineering.
Testing Techniques Software Testing Module ( ) Dr. Samer Hanna.
White Box-based Coverage Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 111 W. Eric Wong Department of Computer Science The.
A Review of Software Testing - P David Coward Reprinted: Information and Software Technology; Vol. 30, No. 3 April 1988 Software Engineering: The Development.
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 Metric; defect removal efficiency, Cyclomate Complexity Defect Seeding Mutation Testing.
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
SAFEWARE System Safety and Computers Chap18:Verification of Safety Author : Nancy G. Leveson University of Washington 1995 by Addison-Wesley Publishing.
Week 5-6 MondayTuesdayWednesdayThursdayFriday Testing III No reading Group meetings Testing IVSection ZFR due ZFR demos Progress report due Readings out.
Workshop on Integrating Software Testing into Programming Courses (WISTPC14:2) Friday July 18, 2014 Introduction to Software Testing.
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.
Foundations of Software Testing Chapter 7: Test Adequacy Measurement and Enhancement Using Mutation Last update: September 3, 2007 These slides are copyrighted.
Structural Coverage. Measurement of structural coverage of code is a means of assessing the thoroughness of testing. Such metrics do not constitute testing.
4 - Conditional Control Structures CHAPTER 4. Introduction A Program is usually not limited to a linear sequence of instructions. In real life, a programme.
Dr. Rob Hasker Dr. Brad Dennis. Coverage  Exercise: Each participant: write down 4 instructions Input to procedure: value given by someone, which person.
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 Practical Considerations (1) 1.
Software Testing and Quality Assurance Syntax-Based Testing (2) 1.
Week#3 Software Quality Engineering.
A Review of Software Testing - P. David Coward
Regression Testing with its types
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.
White-Box Testing.
Introduction to Software Testing Chapter 9.2 Program-based Grammars
White-Box Testing.
Introduction to Software Testing Chapter 5.2 Program-based Grammars
Aditya P. Mathur Purdue University Fall 2007
Software Testing Syntax-based Testing.
Mutation Testing The Mutants are Coming! Copyright © 2017 – Curt Hill.
Regression Testing.
Mutation Testing Moonzoo Kim School of Computing KAIST
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:

© SERG Dependable Software Systems (Mutation) Dependable Software Systems Topics in Mutation Testing and Program Perturbation Material drawn from [Offutt 93,Offutt95,Offutt96]

© SERG Dependable Software Systems (Mutation) What is Mutation Testing? Mutation Testing is a testing technique that focuses on measuring the adequacy of test cases. Mutation Testing is NOT a testing strategy like path or data-flow testing. It does not outline test data selection criteria. Mutation Testing should be used in conjunction with traditional testing techniques, not instead of them.

© SERG Dependable Software Systems (Mutation) Mutation Testing Faults are introduced into the program by creating many versions of the program called mutants. Each mutant contains a single fault. Test cases are applied to the original program and to the mutant program. The goal is to cause the mutant program to fail, thus demonstrating the effectiveness of the test case.

© SERG Dependable Software Systems (Mutation) Test Case Adequacy A test case is adequate if it is useful in detecting faults in a program. A test case can be shown to be adequate by finding at least one mutant program that generates a different output than does the original program for that test case. If the original program and all mutant programs generate the same output, the test case is inadequate.

© SERG Dependable Software Systems (Mutation) Mutant Programs Mutation testing involves the creation of a set of mutant programs of the program being tested. Each mutant differs from the original program by one mutation. A mutation is a single syntactic change that is made to a program statement.

© SERG Dependable Software Systems (Mutation) 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 }

© SERG Dependable Software Systems (Mutation) Categories of Mutation Operators Operand Replacement Operators: –Replace a single operand with another operand or constant. E.g., if (5 > y) Replacing x by constant 5. if (x > 5) Replacing y by constant 5. if (y > x) Replacing x and y with each other. –E.g., if all operators are {+,-,*,**,/} then the following expression a = b * (c - d) will generate 8 mutants: 4 by replacing * 4 by replacing -.

© SERG Dependable Software Systems (Mutation) Categories of Mutation Operators Expression Modification Operators: –Replace an operator or insert new operators. E.g., if (x == y) if (x >= y) Replacing == by >=. if (x == ++y) Inserting ++.

© SERG Dependable Software Systems (Mutation) Statement Modification Operators: –E.g., Delete the else part of the if-else statement. Delete the entire if-else statement. Replace line 3 by a return statement. Categories of Mutation Operators

© SERG Dependable Software Systems (Mutation) Mutation Operators The Mothra mutation system for FORTRAN77 supports 22 mutation operators. E.g., –absolute value insertion –constant for array reference replacement –GOTO label replacement –RETURN statement replacement –statement deletion –unary operator insertion –logical connector replacement –comparable array name replacement

© SERG Dependable Software Systems (Mutation) Why Does Mutation Testing Work? The operators are limited to simple single syntactic changes on the basis of the competent programmer hypothesis.

© SERG Dependable Software Systems (Mutation) The Competent Programmer Hypothesis Programmers are generally very competent and do not create “random” programs. For a given problem, a programmer, if mistaken, will create a program that is very close to a correct program. An incorrect program can be created from a correct program by making some minor change to the correct program.

© SERG Dependable Software Systems (Mutation) Mutation Testing Algorithm Generate program test cases. Run each test case against the original program. –If the output is incorrect, the program must be modified and re-tested. –If the output is correct go to the next step... Construct mutants using a tool like Mothra.

© SERG Dependable Software Systems (Mutation) Mutation Testing Algorithm (Cont’d) Execute each test case against each alive mutant. –If the output of the mutant differs from the output of the original program, the mutant is considered incorrect and is killed. Two kinds of mutants survive: –Functionally equivalent to the original program: Cannot be killed. –Killable: Test cases are insufficient to kill the mutant. New test cases must be created.

© SERG Dependable Software Systems (Mutation) Mutation Score The mutation score for a set of test cases is the percentage of non-equivalent mutants killed by the test data. Mutation Score = 100 * D / (N - E) –D = Dead mutants –N = Number of mutants –E = Number of equivalent mutants A set of test cases is mutation adequate if its mutation score is 100%.

© SERG Dependable Software Systems (Mutation) Evaluation Theoretical and experimental results have shown that mutation testing is an effective approach to measuring the adequacy of test cases. The major drawback of mutation testing is the cost of generating the mutants and executing each test case against them.

© SERG Dependable Software Systems (Mutation) Example of Mutation Testing Costs The FORTRAN 77 version of the max() program generated 44 mutants using Mothra. Most efforts on mutation testing have focused on reducing its cost by reducing the number of mutants while maintaining the effectiveness of the technique.

© SERG Dependable Software Systems (Mutation) Program Perturbation Program Perturbation is a technique to test a program’s robustness. It is based on unexpectedly changing the values of program data during run-time.

© SERG Dependable Software Systems (Mutation) Software Failure Hypothesis Program perturbation is based on the three part software failure hypothesis: –Execution: The fault must be executed. –Infection: The fault must change the data state of the computation directly after the fault location. –Propagation: The erroneous data state must propagate to an output variable.

© SERG Dependable Software Systems (Mutation) Program Perturbation Process The tester must: –inject faults in the data state of an executing program; –trace the impact of the injected fault on the program’s output. The injection is performed by applying a perturbation function that changes the program’s data state.

© SERG Dependable Software Systems (Mutation) The Perturbation Function The perturbation function is a mathematical function that: –takes a data state as its input; –changes the data state according to some specified criteria; –produces a modified data state as output.

© SERG Dependable Software Systems (Mutation) The Fault Injection A program location N is chosen along with a set of input variables I that are in scope at location N. The program is executed until location N. When execution arrives at location N, the resulting data state is changed (perturbed). The subsequent execution will either fail or succeed.

© SERG Dependable Software Systems (Mutation) Program Perturbation Example Assume the following perturbation function: 1. int perturbation (int x) 2. { 3. int newX; 4. newX = x + 20; 5. return newX; 6. }

© SERG Dependable Software Systems (Mutation) Example of a Fault Injection 1. main() 2. { 3. int x; 4. x = ReadInt(); 5. if (x > 0) 6. printf(“X positive”); 7. else 8. printf(“X negative”); 9. } 1. main() 2. { 3. int x; 4. x = ReadInt(); 4.1 x = perturbation(x); 5. if (x > 0) 6. printf(“X positive”); 7. else 8. printf(“X negative”); 9. }

© SERG Dependable Software Systems (Mutation) What Perturbation Testing is and is Not Perturbation testing is NOT a testing technique that outlines test selection and coverage criteria. Rather, perturbation testing is a technique that can be used to measure the reliability of the software (tolerance to faults).

© SERG Dependable Software Systems (Mutation) Evaluation The program is repeatedly executed and injected with faults during each execution. The ratio of the number of failures detected divided by the total number of executions is used to predict failure tolerance.

© SERG Dependable Software Systems (Mutation) References [Offutt93] Offutt, J., Rothermel, G., Zapf, C., An Experimental Evaluation of Selective Mutation, ICSE-15, Baltimore, Maryland, May [Offutt95] Offutt, J., A Practical System for Mutation Testing: Help for the Common Programmer, 12th International Conference on Testing Computer Software, Washington, DC, June, [Offutt96] Offutt, J., Lee, A., Rothermel, G., Zapf, C., An Experimental Determination of Sufficient Mutation Operators, ACM Transactions on Software Engineering and Methodology, Vol. 15, No. 2, April 1996.

© SERG Dependable Software Systems (Mutation) References [Mathur94] Mathur, A., P., Mutation Testing, In the Encyclopedia of Software Engineering, John Wiley, [Voas99] Voas, J., McGraw, G., Software Fault Injection - Inoculating Programs Against Errors, Wiley Computer Publishing. ISBN