Mutation Testing The Mutants are Coming! Copyright © 2017 – Curt Hill.

Slides:



Advertisements
Similar presentations
Mutation Testing Presented by Sharath Kumar Garlapati Vinesh Thummala.
Advertisements

1 Software Testing and Quality Assurance Lecture 9 - Software Testing Techniques.
(c) 2007 Mauro Pezzè & Michal Young Ch 16, slide 1 Fault-Based Testing.
Applied Software Project Management Andrew Stellman & Jennifer Greene Applied Software Project Management Applied Software.
Regression testing Tor Stållhane. What is regression testing – 1 Regression testing is testing done to check that a system update does not re- introduce.
Dr Andy Brooks1 FOR0383 Software Quality Assurance Lecture 1 Introduction Forkröfur/prerequisite: FOR0283 Programming II Website:
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.
Testing Basics of Testing Presented by: Vijay.C.G – Glister Tech.
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.
White-box Testing.
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 Development Problem Analysis and Specification Design Implementation (Coding) Testing, Execution and Debugging Maintenance.
Software Testing Part II March, Fault-based Testing Methodology (white-box) 2 Mutation Testing.
Copyright © 2013 Curt Hill Triggers The Generation of Indirect Actions.
Week 5-6 MondayTuesdayWednesdayThursdayFriday Testing III No reading Group meetings Testing IVSection ZFR due ZFR demos Progress report due Readings out.
/ PSWLAB Evidence-Based Analysis and Inferring Preconditions for Bug Detection By D. Brand, M. Buss, V. C. Sreedhar published in ICSM 2007.
Mutation Testing Breaking the application to test it.
Copyright © Curt Hill Flow of Control A Quick Overview.
CSC 395 – Software Engineering Lecture 27: White-Box Testing.
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 LECTURE 9. OBSERVATIONS ABOUT TESTING “ Testing is the process of executing a program with the intention of finding errors. ” – Myers.
Software Testing and Quality Assurance Syntax-Based Testing (2) 1.
The for Statement A most versatile loop
© 2006 Pearson Education Chapter 3 Part 2 More about Strings and Conditional Statements Loops (for and while) 1.
Software Engineering (CSI 321)
A Review of Software Testing - P. David Coward
Software Testing.
Visit for more Learning Resources
Regression Testing with its types
White-Box Testing Techniques IV
Software Testing.
ICS103 Programming in C Lecture 4: Data Types, Operators & Expressions
Key Ideas from day 1 slides
White-Box Testing Techniques IV
Repetition Structures Chapter 9
Mutation Testing Moonzoo Kim School of Computing KAIST
Topics Introduction to Repetition Structures
Mutation testing Julius Purvinis IFM-0/2.
2_Testing Testing techniques.
An Automated Testing Framework
Types of Testing Visit to more Learning Resources.
Topics Introduction to Repetition Structures
Topics Introduction to File Input and Output
Software Testing (Lecture 11-a)
Design and Programming
Introduction to Software Testing Chapter 5.2 Program-based Grammars
Programming Fundamentals (750113) Ch1. Problem Solving
Introduction to Object-Oriented Programming with Java--Wu
Arrays in Java What, why and how Copyright Curt Hill.
Compound Statements A Quick Overview
Control Structure Testing
Introduction to Repetition Structures
Regression testing Tor Stållhane.
Examining Variables on Flow Paths
The Java switch Statement
Mutation Testing Moonzoo Kim School of Computing KAIST
Topics Introduction to Repetition Structures
Running a Java Program using Blue Jay.
Lecture 14: Testing Testing used to verify object behavior through designed test suites Can test Classes – “unit” testing Object interactions – “integration”
Review of Previous Lesson
Topics Introduction to File Input and Output
The IF Revisited A few more things Copyright © Curt Hill.
IPC144 Introduction to Programming Using C Week 2 – Lesson 2
JavaScript 101 Lesson 8: Loops.
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 The Mutants are Coming! Copyright © 2017 – Curt Hill

Introduction There are several things that we consider worth saving in version control Code Documentation One of these are the tests that we created for the project Mutation testing is testing the tests Copyright © 2017 – Curt Hill

Mutations What we want to do is create a suite of variants of the programs in question This is done after every test has been passed Take a piece of code Modify the code in a small way Bebugging Now run the tests and see if the tests finds that there are defects Do this many times with many different small modifications Copyright © 2017 – Curt Hill

Failures A mutation that goes undetected is always cause for alarm It is either: Inside dead code – which is its own problem An indication that the tests are inadequate Something else is correcting the error before it manifests – highly unlikely After a failure we must write new tests or enhance old ones Copyright © 2017 – Curt Hill

Small Modifications A small modification must not provoke a syntax error Typically only one error So that one error does not mask another There are numerous classes of errors that could be considered These are on next slide Copyright © 2017 – Curt Hill

Classes of Errors Changing an operator Deleting a statement or portion of it Changing a variable in an expression to one with similar scope and type Duplicating a statement Replacing a sub-expression with a constant Changing the type of a variable Changing a condition Others are possible as well Copyright © 2017 – Curt Hill

Suites One small error in a program or class hardly constitutes a test of the tests It is better to generate many such tests Perhaps several different ones for each routine We run all of these tests and keep score of how many errors are found The statistics from this are a measure of the goodness of our testing Copyright © 2017 – Curt Hill

Theory There are two underlying theories behind mutation testing The competent programmer A programmer is more likely to make a simple typo The coupling effect Simple defects cascade into a serious fault Copyright © 2017 – Curt Hill

Kill the Mutant!   Copyright © 2017 – Curt Hill

Requirements In order to kill a mutant three things must happen The test data must execute the mutated statement The test data should distinguish between good and bad The incorrect data must change something that is displayed or tested Copyright © 2017 – Curt Hill

Example Original: if(a && b) c = 1; else c = 0; Mutant: if(a || b) The test must execute the statements The test must be able to distinguish between the two: a = 1, b = 1 will not a = 1, b = 0 will The variable c must be have an effect on something displayed or tested Copyright © 2017 – Curt Hill

Automation Mutation testing is only effective if the testing is automated Unit tests are typically automated so this is the most common way mutation testing occurs Mutation testing is only effective if many mutants are created This typically also involves a program that generates many one error mutants Starts with “correct” code and inserts one randomly selected fault per mutant Copyright © 2017 – Curt Hill

Nice Picture Copyright © 2017 – Curt Hill See: https://www.guru99.com/mutation-testing.html Copyright © 2017 – Curt Hill

Automation What must a mutation testing scheme involve? Many iterations of: Randomly mutate the code Modify the make to run the mutant instead of original Make the unit test Run the unit test Count the results Copyright © 2017 – Curt Hill

History The term bebugging refers to injecting errors into programs The Psychology of Computer Programming by Gerald Weinberg in 1970 First used to test programmer’s ability to find bugs Derived from a technique used on radar operators Proposed by Richard Lipton as a testing scheme in 1971 An implementation by Timothy Budd as a part of his PhD in 1980 Copyright © 2017 – Curt Hill

Conclusion Mutation testing is testing the tests A white box testing of the white box testing Does not expose requirements problems or omissions as black box testing should It should expose unit testing omissions It needs an automated approach like unit testing to be practical Copyright © 2017 – Curt Hill

Exercise Time to make mutants Extract from the unittest assignment the CurtDate.cpp You will now produce mutants by hand Each mutant will have the file name: CurtDate.NX Where N is the initial of your first name Where X is a sequence number starting with 1 Copyright © 2017 – Curt Hill

The Code Most of the routines have no flow of control These should have one mutant per method Those that have flow of control should have one mutant for the Cyclomatic Complexity Number Each student will get one of the following: Several small routines without flow One or two with flow Correct will be split by two Copyright © 2017 – Curt Hill

Rules Each mutant will have one and only one modification Mutant must compile The modification will be one of these: Changing an operator (arithmetic or conditional) Deleting a statement or portion of it Changing a variable in an expression to one with similar scope and type Zip the mutants and email Copyright © 2017 – Curt Hill