What is Mutation testing?
Faults (or mutations) are automatically seeded into your code, then your tests are run. If your tests fail then the mutation is killed, if your tests pass then the mutation lived.
- The quality of your tests can be gauged from the percentage of mutations killed.
Why use mutation testing?
We are essentially asking the question: What’s wrong with line coverage?
- Traditional test coverage (i.e. line, statement, branch, etc.) measures only which code is executed by your tests. It does not check that your tests are actually able to detect faults in the executed code. It is therefore only able to identify code that is definitely not tested.
In general what are some useful techniques for working out if there are gaps in our tests are?
THESE HAVE BEEN STUDIED
- graph coverage techniques -|- may show us that there are portions of code that have never been tested
- logic coverage techniques -|- may show us we haven’t tested different sub-parts of conditions
- program-based mutation testing can be used to “test the tests” -|- if we mutate a program, and it still passes all our tests, something is wrong
What is Program-Based Mutation Testing?
Program-Based Mutation testing (also called “mutation analysis”) is a technique for evaluating the quality of a suite of software tests
What is an example of Program-Based Mutation Testing?
REFER TO SLIDES FOR EXAMPLE
What is the Theory of mutation test?
Mutation testing is a form of syntax-based testing
- Mutations (changes) to the program under test can be defined by a grammar
What is a ground string?
A string in the grammar
- (The term “ground” basically means “not having any variables” – in this context, not having any non-terminals)
What is a mutation operator?
A rule that specifies syntactic variations of strings generated from a grammar
What is a mutant?
The result of one application of a mutation operator on the ground string
- A mutant is a string
What do we mean by killing mutants?
If we have some mutant generated from the original ground string, and we look at one or several of our tests, we can ask: do they “kill” the mutant?
- i.e. Does the test(s) give a different result for the mutant, compared to the original?
- If it does, it’s said to “kill” the mutant.
Syntax-based coverage criteria – mutant coverage
When creating mutants (i.e. invalid strings), two simple criteria:
- use every operator once or
- use every production once
What are test requirements?
TR is test requirements. TR are descriptions of test cases that will be refined into executable tests
What is Mutation Production Coverage (MPC)?
For each mutation operator, TR contains several requirements, to create one mutated string m that includes every production that can be mutated by that operator
What is Mutation Operator Coverage (MOC)?
For each mutation operator, TR contains exactly one requirement, to create a mutated string m that is derived using the mutation operator
What are some practical concerns with mutation - Coverage criteria – practical concerns?
The number of test requirements for mutation is somewhat difficult to quantify because it depends on the syntax of the artifact as well as the mutation operators
- In most situations, mutation yields more test requirements than any other coverage criterion
What are some frameworks we can use for mutation testing?
Mutation testing is difficult to apply by hand and automation is more complicated than for most other criteria.
- As a result, mutation is widely considered a high-end coverage criterion, more effective than most but also more expensive.
- One common use of mutation is as a sort of gold standard in experimental studies for comparative evaluation of other test criteria.
What are the advantages and disadvantages of using the frameworks?
Advantages:
- Identifies weak/ineffective tests I Very effective at finding problems
- Helps quantify how useful your tests are
Disadvantages:
- Can be time-consuming (large number of mutants to generate, whole test suite needs to be run many times)
- Results require some familiarity with mutation testing to be properly understood
Mutation Testing Example
REFER TO SLIDES