SlideShare a Scribd company logo
© Computas AS 26.01.15
Mutation Testing
with Mutant and PIT
Filip van Laenen & Markus Schirp
OOP 2015
2015-01-26
2 © Computas AS 26.01.15
Agenda
• Basics of mutation testing
• Relation to other testing techniques
• Example
• Mutation testing techniques
• Mutation testing tools
• Personal experiences and recommendations
3 © Computas AS 26.01.15
Basics of
Mutation Testing
4 © Computas AS 26.01.15
Mutation Testing in a Nutshell
Seeking The Summoner @ The Daily WTF
http://thedailywtf.com/Articles/Seeking-The-Summoner.aspx
5 © Computas AS 26.01.15
Mutation Testing in a Nutshell (cont'd)
6 © Computas AS 26.01.15
Mutation Testing in a Nutshell (cont'd)
7 © Computas AS 26.01.15
Mutation Testing in a Nutshell (cont'd)
• Unit tests guard the source code
• But who guards the guardians?
• Do the unit tests cover all source code?
• Lines?
• Branches?
• Paths?
• Semantics?
• Do the unit tests test the right things?
Mutation testing tests the tests!
8 © Computas AS 26.01.15
Mutation Testing in a Nutshell (cont'd)
9 © Computas AS 26.01.15
Mutation Testing in a Nutshell (cont'd)
10 © Computas AS 26.01.15
Mutation Testing in a Nutshell (cont'd)
11 © Computas AS 26.01.15
Mutation Testing in a Nutshell (cont'd)
12 © Computas AS 26.01.15
Mutation Testing in a Nutshell (cont'd)
13 © Computas AS 26.01.15
Mutation Testing in a Nutshell (cont'd)
14 © Computas AS 26.01.15
Mutation Testing in a Nutshell (cont'd)
int max(int a, int b) {
return (a < b) ? b : a;
}
int max(int a, int b) {
return (a <= b) ? b : a;
}
15 © Computas AS 26.01.15
Mutation Testing in a Nutshell (cont'd)
“
16 © Computas AS 26.01.15
Does Mutation Testing Work?
In practice, if the software contains a
fault, there will usually be a set of
mutants that can only be killed by a test
case that also detects that fault.
Geist et. al., “Estimation and Enhancement of Real-time
Software Reliability through Mutation Analysis,” 1992
“
17 © Computas AS 26.01.15
Does Mutation Testing Work? (cont'd)
Complex faults are coupled to simple
faults in such a way that a test data set
that detects all simple faults in a program
will detect most complex faults.
K. Wah, “Fault Coupling in Finite Bijective Functions,”
1995
18 © Computas AS 26.01.15
Does Mutation Testing Work? (cont'd)
• “Generated mutants are similar to real faults.”
• Andrews, Briand, Labiche, ICSE 2005
• “Mutation testing is more powerful than
statement or branch coverage.”
• Walsh, Ph.D. Thesis, State University of New York at
Binghampton, 1985
• “Mutation testing is superior to data flow
coverage criteria.”
• Frankl, Weiss, Hu, Journal of Systems and Software,
1997
19 © Computas AS 26.01.15
Relation to Other
Testing Techniques
20 © Computas AS 26.01.15
Relation to Other Testing Techniques
• Unit tests
• Test-Driven Development (TDD)
• Test coverage
• Static code analysis
• Fuzz testing
21 © Computas AS 26.01.15
Relation to Other Testing Techniques
22 © Computas AS 26.01.15
Is Mutation Testing New?
• R. Lipton, “Fault Diagnosis of Computer
Programs,” 1971
• R. Lipton et. al., “Hints on Test Data Selection:
Help for the Practicing Programmer,” 1978
• Historical obstacles:
• No unit testing
• No TDD
• Inefficient implementation
• Hence time-consuming
• No integration with IDEs
23 © Computas AS 26.01.15
Practical Example
of Mutation Testing
24 © Computas AS 26.01.15
Code Along…
https://github.com/computas-fvl/oop2015
git clone 
https://github.com/computas-fvl/oop2015.git
mvn clean site:site 
org.pitest:pitest-maven:mutationCoverage
25 © Computas AS 26.01.15
Mutation Testing
Techniques
26 © Computas AS 26.01.15
Mutation Testing Techniques
• Three aspects:
• Mutation injection
• Mutation types
• Unit test selection per mutant
• Key properties:
• Efficiency
• Performance
• Coverage
27 © Computas AS 26.01.15
Mutation Injection
• Source code mutation
• Intermediate code mutation
• Binary code mutation
• Caveats:
• De-mutation (for reporting)
• Compilation errors
• Invalid binary code
• Leaked state
28 © Computas AS 26.01.15
Mutation Types
• Some mutations never change behaviour
• Constants reused by unit tests
• Log messages
• Exception messages
• Some mutations can change behaviour
• Switching between < and ≠
• Switching between < and ≤
• Some mutations always change behaviour
• Switching between < and ≥
29 © Computas AS 26.01.15
Mutation Types (cont'd)
int max(int a, int b) {
return (a < b) ? b : a;
}
int max(int a, int b) {
return (a <= b) ? b : a;
}
int max(int a, int b) {
return (a >= b) ? b : a;
}
30 © Computas AS 26.01.15
Mutation Types (cont'd)
for (int i = 0; i < 10; i++) …
for (int i = 0; i != 10; i++) …
for (int i = 0; i >= 10; i++) …
31 © Computas AS 26.01.15
Mutation Types Guaranteed to Change
Behaviour
• Negation of the comparison
• Switching between = and ≠
• Switching between < and ≥
• Switching between > and ≤
• Negation of boolean conditions
• Adding a ¬, ! or ~
• Shortcutting boolean conditions
• Replacement with True or False
*
32 © Computas AS 26.01.15
Unit Test Selection
• Goal: find the unit test that “kills” the mutant
• Selection aids:
• Hints
• Name/package matching
• Code coverage tools
• Incremental mutation testing
• Other heuristics
33 © Computas AS 26.01.15
Unit Test Selection (cont'd)
• System:
• 50 classes
• 20 unit tests per class
• 1 ms per unit test
• Unit testing time: 50 × 20 × 1ms = 1s
• 10 mutants per class:
• Brute-force: 10 × 50 × 1s = 6m 20s
• Educated: 10 × 50 × 20 × 1ms = 10s
34 © Computas AS 26.01.15
Unit Test Selection (cont'd)
• System:
• 500 classes
• 20 unit tests per class
• 1 ms per unit test
• Unit testing time: 500 × 20 × 1ms = 10s
• 10 mutants per class:
• Brute-force: 10 × 500 × 10s = 13h 53m 20s
• Educated: 10 × 500 × 20 × 1ms = 1m 40s
35 © Computas AS 26.01.15
Complexity
• f: Number of function points
• φ: Number of function points per class, ≥ 1
• τ: Number of unit tests per function point, ≥ 1
• μ: Number of mutants per function point, ≥ 1
• Brute-force: (f × τ) × (f × μ) = τ × μ × f²
• Educated force: τ × μ × φ × f
• Ideal: τ × μ × f
36 © Computas AS 26.01.15
Complexity (cont'd)
• c: Number of classes
• φ: Number of function points per class, ≥ 1
• τ: Number of unit tests per function point, ≥ 1
• μ: Number of mutants per function point, ≥ 1
• Brute-force: (f × τ) × (f × μ) = τ × μ × φ² × c²
• Educated force: τ × μ × φ² × c
• Ideal: τ × μ × φ × c
37 © Computas AS 26.01.15
Loops
for (int i = 0; i < 10; i++) …
for (int i = 0; i < 10; i--) …
38 © Computas AS 26.01.15
Infinite Loops
• Terminate mutants that take too long to run
• What's “too long”?
• Ruins the performance
• Can be hard to predict
39 © Computas AS 26.01.15
Other Problems
• Recursion:
• Stack overflows
• Out of memory exceptions
• Syntax errors
• Leaked state
• Segmentation faults
40 © Computas AS 26.01.15
Mutation Testing
Tools
41 © Computas AS 26.01.15
Mutation Testing Tools
• Java:
• PIT
• Ruby:
• Mutant
• Heckle
• PHP
• Humbug
• C#:
• NinjaTurtles
42 © Computas AS 26.01.15
PIT
• Java
• Junit & TestNG
• Maven or command-line
• Operates on byte code
• Large set of mutators
• Also possibly equivalent mutators available
• Highly configurable
• Sensible defaults
• http://pitest.org/
43 © Computas AS 26.01.15
PIT Mutators
• Conditionals Boundary
• Negate Conditionals
• Remove Conditionals*
• Math
• Increments
• Invert Negatives
• Inline Constant*
• Return Values
• Void Method Calls
• Non Void Method Calls*
• Constructor Calls*
44 © Computas AS 26.01.15
PIT Sample Report
45 © Computas AS 26.01.15
Jester
• Java
• JUnit
• Usually run from the command-line
• Grester for Maven2
• Operates on source code
• Runs all unit tests on all classes
• Reporting and documentation could be better
• http://jester.sourceforge.net/
• http://sourceforge.net/projects/grester/
46 © Computas AS 26.01.15
Jester Sample Report Overview
47 © Computas AS 26.01.15
Jester Sample Detailed Report
48 © Computas AS 26.01.15
Pester and Nester
• Pester
• Jester for Python
• PyUnit
• Nester
• Port of Jester for C#
• NUnit
• Integrated with Visual Studio
• But outdated…
• http://nester.sourceforge.net/
49 © Computas AS 26.01.15
Nester Sample Report
50 © Computas AS 26.01.15
Jumble
• Java
• JUnit
• Run from the command-line
• Operates on byte code
• Runs unit tests on a class
• Reporting and documentation could be better
• Claims to be faster than Jester
• http://jumble.sourceforge.net/index.html
51 © Computas AS 26.01.15
Jumble Sample Report
Mutating Foo
Tests: FooTest
Mutation points = 12, unit test time limit 2.02s
..
M FAIL: Foo:31: negated conditional
M FAIL: Foo:33: negated conditional
M FAIL: Foo:34: - -> +
M FAIL: Foo:35: negated conditional
......
Score: 67%
52 © Computas AS 26.01.15
Mutant
• Ruby 1.9 up to 2.2
• Rspec2 and Rspec3
• Usually run from the command-line
• Good to-the-point reporting
• Good performance
• OK documentation
• Active project
• https://github.com/mbj/mutant
53 © Computas AS 26.01.15
Heckle
• Ruby 1.8
• Doesn't work on Ruby 1.9
• Test::Unit and rSpec
• Usually run from the command-line
• Runs a set of unit tests on a class or a method
• Good to-the-point reporting
• Acceptable performance
• Virtually no documentation
• http://rubyforge.org/projects/seattlerb/
• http://docs.seattlerb.org/heckle/
54 © Computas AS 26.01.15
Heckle Mutations
• Booleans
• Numbers
• Strings
• Symbols
• Ranges
• Regexes
• Branches (if, while, unless, until)
55 © Computas AS 26.01.15
Humbug
• PHP 5.4 or greater
• PHPUnit
• Usually run from the command-line
• OK documentation
• Active project
• https://github.com/padraic/humbug
56 © Computas AS 26.01.15
NinjaTurtles
• .Net:
• C#
• Visual Basic/VB.NET
• Any other .NET language code
• Doesn't seem much alive
• http://www.mutation-testing.net/
57 © Computas AS 26.01.15
NinjaTurtles Mutations
• Sequence point deletion
• Arithmetic operator substitution (*, /, +, -, %)
• Bitwise operator substitution (&, |, ^)
• Branch substituion (condition, always and never
branch)
• Conditional boundary substition (< and <=, >
and >=)
• Substitution of reads from variables,
parameters and fields of the same type
• Substitution of writes to variables of the same
type
58 © Computas AS 26.01.15
Personal Experiences
and Recommendations
59 © Computas AS 26.01.15
Experiences and Recommendations
• Use mutation testing from day 1
• Start on a small code base
• Keep things simple
• Have small interfaces
• Select a good tool
• Configurable
• Flexible
• One that can output the mutant
60 © Computas AS 26.01.15
Experiences and Recommendations
(cont'd)
• Believe the tool
• Or try to proof that the tool is wrong
• Fix the problem
• Don't turn mutation testing off
• Embrace the “more than 100%” test coverage
• Semantic coverage
• Less code
• More unit tests
• More intelligent unit tests
61 © Computas AS 26.01.15
Improvements
62 © Computas AS 26.01.15
Improvements
• Integration with more unit testing frameworks
• Better unit test–source code mapping
• Better heuristics
• Parallellisation
• Better reporting
• IDE integration
• Building tool integration

More Related Content

Viewers also liked

Mutation testing
Mutation testingMutation testing
Mutation testing
Raúl Ávila
 
GeeCON - Improve your tests with Mutation Testing
GeeCON - Improve your tests with Mutation TestingGeeCON - Improve your tests with Mutation Testing
GeeCON - Improve your tests with Mutation Testing
Nicolas Fränkel
 
MUTANTS KILLER (Revised) - PIT: state of the art of mutation testing system
MUTANTS KILLER (Revised) - PIT: state of the art of mutation testing system MUTANTS KILLER (Revised) - PIT: state of the art of mutation testing system
MUTANTS KILLER (Revised) - PIT: state of the art of mutation testing system
Tarin Gamberini
 
Mutation Testing
Mutation TestingMutation Testing
Mutation Testing
ESUG
 
Javantura v3 - Mutation Testing for everyone – Nicolas Fränkel
Javantura v3 - Mutation Testing for everyone – Nicolas FränkelJavantura v3 - Mutation Testing for everyone – Nicolas Fränkel
Javantura v3 - Mutation Testing for everyone – Nicolas Fränkel
HUJAK - Hrvatska udruga Java korisnika / Croatian Java User Association
 
Mutation testing
Mutation testingMutation testing
Mutation testingTao He
 

Viewers also liked (6)

Mutation testing
Mutation testingMutation testing
Mutation testing
 
GeeCON - Improve your tests with Mutation Testing
GeeCON - Improve your tests with Mutation TestingGeeCON - Improve your tests with Mutation Testing
GeeCON - Improve your tests with Mutation Testing
 
MUTANTS KILLER (Revised) - PIT: state of the art of mutation testing system
MUTANTS KILLER (Revised) - PIT: state of the art of mutation testing system MUTANTS KILLER (Revised) - PIT: state of the art of mutation testing system
MUTANTS KILLER (Revised) - PIT: state of the art of mutation testing system
 
Mutation Testing
Mutation TestingMutation Testing
Mutation Testing
 
Javantura v3 - Mutation Testing for everyone – Nicolas Fränkel
Javantura v3 - Mutation Testing for everyone – Nicolas FränkelJavantura v3 - Mutation Testing for everyone – Nicolas Fränkel
Javantura v3 - Mutation Testing for everyone – Nicolas Fränkel
 
Mutation testing
Mutation testingMutation testing
Mutation testing
 

Similar to Oop 2015 – Mutation Testing

How good are your tests?
How good are your tests?How good are your tests?
How good are your tests?
Noam Shaish
 
Effective Test Suites for ! Mixed Discrete-Continuous Stateflow Controllers
Effective Test Suites for ! Mixed Discrete-Continuous Stateflow ControllersEffective Test Suites for ! Mixed Discrete-Continuous Stateflow Controllers
Effective Test Suites for ! Mixed Discrete-Continuous Stateflow Controllers
Lionel Briand
 
SSBSE 2020 keynote
SSBSE 2020 keynoteSSBSE 2020 keynote
SSBSE 2020 keynote
Shiva Nejati
 
Testing of Cyber-Physical Systems: Diversity-driven Strategies
Testing of Cyber-Physical Systems: Diversity-driven StrategiesTesting of Cyber-Physical Systems: Diversity-driven Strategies
Testing of Cyber-Physical Systems: Diversity-driven Strategies
Lionel Briand
 
SAST, fight against potential vulnerabilities
SAST, fight against potential vulnerabilitiesSAST, fight against potential vulnerabilities
SAST, fight against potential vulnerabilities
Andrey Karpov
 
Unit testing basics
Unit testing basicsUnit testing basics
Automatic Test Pattern Generation (Testing of VLSI Design)
Automatic Test Pattern Generation (Testing of VLSI Design)Automatic Test Pattern Generation (Testing of VLSI Design)
Automatic Test Pattern Generation (Testing of VLSI Design)
Usha Mehta
 
DFT-Lecture regarding the JTAG, MBIST introduction to DFT
DFT-Lecture regarding the JTAG, MBIST introduction to DFTDFT-Lecture regarding the JTAG, MBIST introduction to DFT
DFT-Lecture regarding the JTAG, MBIST introduction to DFT
jagneswardharua
 
Mike Bartley - Innovations for Testing Parallel Software - EuroSTAR 2012
Mike Bartley - Innovations for Testing Parallel Software - EuroSTAR 2012Mike Bartley - Innovations for Testing Parallel Software - EuroSTAR 2012
Mike Bartley - Innovations for Testing Parallel Software - EuroSTAR 2012
TEST Huddle
 
Dealing with the Three Horrible Problems in Verification
Dealing with the Three Horrible Problems in VerificationDealing with the Three Horrible Problems in Verification
Dealing with the Three Horrible Problems in VerificationDVClub
 
Chapter 14 software testing techniques
Chapter 14 software testing techniquesChapter 14 software testing techniques
Chapter 14 software testing techniques
SHREEHARI WADAWADAGI
 
Evaluating Model Testing and Model Checking for Finding Requirements Violatio...
Evaluating Model Testing and Model Checking for Finding Requirements Violatio...Evaluating Model Testing and Model Checking for Finding Requirements Violatio...
Evaluating Model Testing and Model Checking for Finding Requirements Violatio...
Lionel Briand
 
Qt test framework
Qt test frameworkQt test framework
Qt test framework
ICS
 
Automated Testing of Hybrid Simulink/Stateflow Controllers
Automated Testing of Hybrid Simulink/Stateflow ControllersAutomated Testing of Hybrid Simulink/Stateflow Controllers
Automated Testing of Hybrid Simulink/Stateflow Controllers
Lionel Briand
 
Testing Dynamic Behavior in Executable Software Models - Making Cyber-physica...
Testing Dynamic Behavior in Executable Software Models - Making Cyber-physica...Testing Dynamic Behavior in Executable Software Models - Making Cyber-physica...
Testing Dynamic Behavior in Executable Software Models - Making Cyber-physica...
Lionel Briand
 
Shift-Left Testing: QA in a DevOps World by David Laulusa
Shift-Left Testing: QA in a DevOps World by David LaulusaShift-Left Testing: QA in a DevOps World by David Laulusa
Shift-Left Testing: QA in a DevOps World by David Laulusa
QA or the Highway
 
Mutation testing (OOP 2012, 2012-JAN-24)
Mutation testing (OOP 2012, 2012-JAN-24)Mutation testing (OOP 2012, 2012-JAN-24)
Mutation testing (OOP 2012, 2012-JAN-24)
Filip Van Laenen
 
SOFTWARE TESTING W4_watermark.pdf
SOFTWARE TESTING W4_watermark.pdfSOFTWARE TESTING W4_watermark.pdf
SOFTWARE TESTING W4_watermark.pdf
GayathriRHICETCSESTA
 
Automated testing of ASP .Net Core applications
Automated testing of ASP .Net Core applications Automated testing of ASP .Net Core applications
Automated testing of ASP .Net Core applications
nispas
 
Automated and Scalable Solutions for Software Testing: The Essential Role of ...
Automated and Scalable Solutions for Software Testing: The Essential Role of ...Automated and Scalable Solutions for Software Testing: The Essential Role of ...
Automated and Scalable Solutions for Software Testing: The Essential Role of ...
Lionel Briand
 

Similar to Oop 2015 – Mutation Testing (20)

How good are your tests?
How good are your tests?How good are your tests?
How good are your tests?
 
Effective Test Suites for ! Mixed Discrete-Continuous Stateflow Controllers
Effective Test Suites for ! Mixed Discrete-Continuous Stateflow ControllersEffective Test Suites for ! Mixed Discrete-Continuous Stateflow Controllers
Effective Test Suites for ! Mixed Discrete-Continuous Stateflow Controllers
 
SSBSE 2020 keynote
SSBSE 2020 keynoteSSBSE 2020 keynote
SSBSE 2020 keynote
 
Testing of Cyber-Physical Systems: Diversity-driven Strategies
Testing of Cyber-Physical Systems: Diversity-driven StrategiesTesting of Cyber-Physical Systems: Diversity-driven Strategies
Testing of Cyber-Physical Systems: Diversity-driven Strategies
 
SAST, fight against potential vulnerabilities
SAST, fight against potential vulnerabilitiesSAST, fight against potential vulnerabilities
SAST, fight against potential vulnerabilities
 
Unit testing basics
Unit testing basicsUnit testing basics
Unit testing basics
 
Automatic Test Pattern Generation (Testing of VLSI Design)
Automatic Test Pattern Generation (Testing of VLSI Design)Automatic Test Pattern Generation (Testing of VLSI Design)
Automatic Test Pattern Generation (Testing of VLSI Design)
 
DFT-Lecture regarding the JTAG, MBIST introduction to DFT
DFT-Lecture regarding the JTAG, MBIST introduction to DFTDFT-Lecture regarding the JTAG, MBIST introduction to DFT
DFT-Lecture regarding the JTAG, MBIST introduction to DFT
 
Mike Bartley - Innovations for Testing Parallel Software - EuroSTAR 2012
Mike Bartley - Innovations for Testing Parallel Software - EuroSTAR 2012Mike Bartley - Innovations for Testing Parallel Software - EuroSTAR 2012
Mike Bartley - Innovations for Testing Parallel Software - EuroSTAR 2012
 
Dealing with the Three Horrible Problems in Verification
Dealing with the Three Horrible Problems in VerificationDealing with the Three Horrible Problems in Verification
Dealing with the Three Horrible Problems in Verification
 
Chapter 14 software testing techniques
Chapter 14 software testing techniquesChapter 14 software testing techniques
Chapter 14 software testing techniques
 
Evaluating Model Testing and Model Checking for Finding Requirements Violatio...
Evaluating Model Testing and Model Checking for Finding Requirements Violatio...Evaluating Model Testing and Model Checking for Finding Requirements Violatio...
Evaluating Model Testing and Model Checking for Finding Requirements Violatio...
 
Qt test framework
Qt test frameworkQt test framework
Qt test framework
 
Automated Testing of Hybrid Simulink/Stateflow Controllers
Automated Testing of Hybrid Simulink/Stateflow ControllersAutomated Testing of Hybrid Simulink/Stateflow Controllers
Automated Testing of Hybrid Simulink/Stateflow Controllers
 
Testing Dynamic Behavior in Executable Software Models - Making Cyber-physica...
Testing Dynamic Behavior in Executable Software Models - Making Cyber-physica...Testing Dynamic Behavior in Executable Software Models - Making Cyber-physica...
Testing Dynamic Behavior in Executable Software Models - Making Cyber-physica...
 
Shift-Left Testing: QA in a DevOps World by David Laulusa
Shift-Left Testing: QA in a DevOps World by David LaulusaShift-Left Testing: QA in a DevOps World by David Laulusa
Shift-Left Testing: QA in a DevOps World by David Laulusa
 
Mutation testing (OOP 2012, 2012-JAN-24)
Mutation testing (OOP 2012, 2012-JAN-24)Mutation testing (OOP 2012, 2012-JAN-24)
Mutation testing (OOP 2012, 2012-JAN-24)
 
SOFTWARE TESTING W4_watermark.pdf
SOFTWARE TESTING W4_watermark.pdfSOFTWARE TESTING W4_watermark.pdf
SOFTWARE TESTING W4_watermark.pdf
 
Automated testing of ASP .Net Core applications
Automated testing of ASP .Net Core applications Automated testing of ASP .Net Core applications
Automated testing of ASP .Net Core applications
 
Automated and Scalable Solutions for Software Testing: The Essential Role of ...
Automated and Scalable Solutions for Software Testing: The Essential Role of ...Automated and Scalable Solutions for Software Testing: The Essential Role of ...
Automated and Scalable Solutions for Software Testing: The Essential Role of ...
 

More from Filip Van Laenen

Drawing for IT Architects
Drawing for IT ArchitectsDrawing for IT Architects
Drawing for IT Architects
Filip Van Laenen
 
How JSR 385 could have saved the Mars Climate Orbiter
How JSR 385 could have saved the Mars Climate OrbiterHow JSR 385 could have saved the Mars Climate Orbiter
How JSR 385 could have saved the Mars Climate Orbiter
Filip Van Laenen
 
How JSR-385 Could Have Saved the Mars Climate Orbiter
How JSR-385 Could Have Saved the Mars Climate OrbiterHow JSR-385 Could Have Saved the Mars Climate Orbiter
How JSR-385 Could Have Saved the Mars Climate Orbiter
Filip Van Laenen
 
Clouds with Trenches and Sharp Edges
Clouds with Trenches and Sharp EdgesClouds with Trenches and Sharp Edges
Clouds with Trenches and Sharp Edges
Filip Van Laenen
 
Become an SVG Architect, not a PowerPoint Architect
Become an SVG Architect, not a PowerPoint ArchitectBecome an SVG Architect, not a PowerPoint Architect
Become an SVG Architect, not a PowerPoint Architect
Filip Van Laenen
 
Dial M for Mutation
Dial M for MutationDial M for Mutation
Dial M for Mutation
Filip Van Laenen
 
Mutasjonstesting – Lag bugs for å få bedre kode
Mutasjonstesting – Lag bugs for å få bedre kodeMutasjonstesting – Lag bugs for å få bedre kode
Mutasjonstesting – Lag bugs for å få bedre kode
Filip Van Laenen
 
Hvem kommer til å vinne kommunevalget?
Hvem kommer til å vinne kommunevalget?Hvem kommer til å vinne kommunevalget?
Hvem kommer til å vinne kommunevalget?
Filip Van Laenen
 
Five Inconvenient Truths about REST
Five Inconvenient Truths about RESTFive Inconvenient Truths about REST
Five Inconvenient Truths about REST
Filip Van Laenen
 
How Free Data Can Drive Some of the Monkey Business Out of Political Journali...
How Free Data Can Drive Some of the Monkey Business Out of Political Journali...How Free Data Can Drive Some of the Monkey Business Out of Political Journali...
How Free Data Can Drive Some of the Monkey Business Out of Political Journali...
Filip Van Laenen
 
#NoEstimates – Smidig 2014
 #NoEstimates – Smidig 2014 #NoEstimates – Smidig 2014
#NoEstimates – Smidig 2014Filip Van Laenen
 
#NoEstimates – Javazone 2014
#NoEstimates – Javazone 2014#NoEstimates – Javazone 2014
#NoEstimates – Javazone 2014
Filip Van Laenen
 
Tre ubeleilige sannheter om REST
Tre ubeleilige sannheter om RESTTre ubeleilige sannheter om REST
Tre ubeleilige sannheter om REST
Filip Van Laenen
 
What Architects Really Do
What Architects Really DoWhat Architects Really Do
What Architects Really Do
Filip Van Laenen
 
Hvorfor stole på e-valg 2011/13?
Hvorfor stole på e-valg 2011/13?Hvorfor stole på e-valg 2011/13?
Hvorfor stole på e-valg 2011/13?Filip Van Laenen
 
SVG (Devoxx 2011, 2011-NOV-14)
SVG (Devoxx 2011, 2011-NOV-14)SVG (Devoxx 2011, 2011-NOV-14)
SVG (Devoxx 2011, 2011-NOV-14)
Filip Van Laenen
 
SVG (Framsia, 27-SEP-2011)
SVG (Framsia, 27-SEP-2011)SVG (Framsia, 27-SEP-2011)
SVG (Framsia, 27-SEP-2011)
Filip Van Laenen
 

More from Filip Van Laenen (17)

Drawing for IT Architects
Drawing for IT ArchitectsDrawing for IT Architects
Drawing for IT Architects
 
How JSR 385 could have saved the Mars Climate Orbiter
How JSR 385 could have saved the Mars Climate OrbiterHow JSR 385 could have saved the Mars Climate Orbiter
How JSR 385 could have saved the Mars Climate Orbiter
 
How JSR-385 Could Have Saved the Mars Climate Orbiter
How JSR-385 Could Have Saved the Mars Climate OrbiterHow JSR-385 Could Have Saved the Mars Climate Orbiter
How JSR-385 Could Have Saved the Mars Climate Orbiter
 
Clouds with Trenches and Sharp Edges
Clouds with Trenches and Sharp EdgesClouds with Trenches and Sharp Edges
Clouds with Trenches and Sharp Edges
 
Become an SVG Architect, not a PowerPoint Architect
Become an SVG Architect, not a PowerPoint ArchitectBecome an SVG Architect, not a PowerPoint Architect
Become an SVG Architect, not a PowerPoint Architect
 
Dial M for Mutation
Dial M for MutationDial M for Mutation
Dial M for Mutation
 
Mutasjonstesting – Lag bugs for å få bedre kode
Mutasjonstesting – Lag bugs for å få bedre kodeMutasjonstesting – Lag bugs for å få bedre kode
Mutasjonstesting – Lag bugs for å få bedre kode
 
Hvem kommer til å vinne kommunevalget?
Hvem kommer til å vinne kommunevalget?Hvem kommer til å vinne kommunevalget?
Hvem kommer til å vinne kommunevalget?
 
Five Inconvenient Truths about REST
Five Inconvenient Truths about RESTFive Inconvenient Truths about REST
Five Inconvenient Truths about REST
 
How Free Data Can Drive Some of the Monkey Business Out of Political Journali...
How Free Data Can Drive Some of the Monkey Business Out of Political Journali...How Free Data Can Drive Some of the Monkey Business Out of Political Journali...
How Free Data Can Drive Some of the Monkey Business Out of Political Journali...
 
#NoEstimates – Smidig 2014
 #NoEstimates – Smidig 2014 #NoEstimates – Smidig 2014
#NoEstimates – Smidig 2014
 
#NoEstimates – Javazone 2014
#NoEstimates – Javazone 2014#NoEstimates – Javazone 2014
#NoEstimates – Javazone 2014
 
Tre ubeleilige sannheter om REST
Tre ubeleilige sannheter om RESTTre ubeleilige sannheter om REST
Tre ubeleilige sannheter om REST
 
What Architects Really Do
What Architects Really DoWhat Architects Really Do
What Architects Really Do
 
Hvorfor stole på e-valg 2011/13?
Hvorfor stole på e-valg 2011/13?Hvorfor stole på e-valg 2011/13?
Hvorfor stole på e-valg 2011/13?
 
SVG (Devoxx 2011, 2011-NOV-14)
SVG (Devoxx 2011, 2011-NOV-14)SVG (Devoxx 2011, 2011-NOV-14)
SVG (Devoxx 2011, 2011-NOV-14)
 
SVG (Framsia, 27-SEP-2011)
SVG (Framsia, 27-SEP-2011)SVG (Framsia, 27-SEP-2011)
SVG (Framsia, 27-SEP-2011)
 

Recently uploaded

Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdf
Globus
 
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Łukasz Chruściel
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus
 
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Mind IT Systems
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
Fermin Galan
 
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
Juraj Vysvader
 
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdfAutomated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
timtebeek1
 
AI Genie Review: World’s First Open AI WordPress Website Creator
AI Genie Review: World’s First Open AI WordPress Website CreatorAI Genie Review: World’s First Open AI WordPress Website Creator
AI Genie Review: World’s First Open AI WordPress Website Creator
Google
 
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissancesAtelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Neo4j
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
Ortus Solutions, Corp
 
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOMLORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
lorraineandreiamcidl
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
rickgrimesss22
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
Donna Lenk
 
Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
NYGGS Automation Suite
 
Mobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona InfotechMobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona Infotech
Drona Infotech
 
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI AppAI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
Google
 
APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)
Boni García
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
XfilesPro
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus
 

Recently uploaded (20)

Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdf
 
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
 
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
 
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
 
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdfAutomated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
 
AI Genie Review: World’s First Open AI WordPress Website Creator
AI Genie Review: World’s First Open AI WordPress Website CreatorAI Genie Review: World’s First Open AI WordPress Website Creator
AI Genie Review: World’s First Open AI WordPress Website Creator
 
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissancesAtelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissances
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
 
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOMLORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
 
Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
 
Mobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona InfotechMobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona Infotech
 
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI AppAI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
 
APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
 

Oop 2015 – Mutation Testing

  • 1. © Computas AS 26.01.15 Mutation Testing with Mutant and PIT Filip van Laenen & Markus Schirp OOP 2015 2015-01-26
  • 2. 2 © Computas AS 26.01.15 Agenda • Basics of mutation testing • Relation to other testing techniques • Example • Mutation testing techniques • Mutation testing tools • Personal experiences and recommendations
  • 3. 3 © Computas AS 26.01.15 Basics of Mutation Testing
  • 4. 4 © Computas AS 26.01.15 Mutation Testing in a Nutshell Seeking The Summoner @ The Daily WTF http://thedailywtf.com/Articles/Seeking-The-Summoner.aspx
  • 5. 5 © Computas AS 26.01.15 Mutation Testing in a Nutshell (cont'd)
  • 6. 6 © Computas AS 26.01.15 Mutation Testing in a Nutshell (cont'd)
  • 7. 7 © Computas AS 26.01.15 Mutation Testing in a Nutshell (cont'd) • Unit tests guard the source code • But who guards the guardians? • Do the unit tests cover all source code? • Lines? • Branches? • Paths? • Semantics? • Do the unit tests test the right things? Mutation testing tests the tests!
  • 8. 8 © Computas AS 26.01.15 Mutation Testing in a Nutshell (cont'd)
  • 9. 9 © Computas AS 26.01.15 Mutation Testing in a Nutshell (cont'd)
  • 10. 10 © Computas AS 26.01.15 Mutation Testing in a Nutshell (cont'd)
  • 11. 11 © Computas AS 26.01.15 Mutation Testing in a Nutshell (cont'd)
  • 12. 12 © Computas AS 26.01.15 Mutation Testing in a Nutshell (cont'd)
  • 13. 13 © Computas AS 26.01.15 Mutation Testing in a Nutshell (cont'd)
  • 14. 14 © Computas AS 26.01.15 Mutation Testing in a Nutshell (cont'd) int max(int a, int b) { return (a < b) ? b : a; } int max(int a, int b) { return (a <= b) ? b : a; }
  • 15. 15 © Computas AS 26.01.15 Mutation Testing in a Nutshell (cont'd)
  • 16. “ 16 © Computas AS 26.01.15 Does Mutation Testing Work? In practice, if the software contains a fault, there will usually be a set of mutants that can only be killed by a test case that also detects that fault. Geist et. al., “Estimation and Enhancement of Real-time Software Reliability through Mutation Analysis,” 1992
  • 17. “ 17 © Computas AS 26.01.15 Does Mutation Testing Work? (cont'd) Complex faults are coupled to simple faults in such a way that a test data set that detects all simple faults in a program will detect most complex faults. K. Wah, “Fault Coupling in Finite Bijective Functions,” 1995
  • 18. 18 © Computas AS 26.01.15 Does Mutation Testing Work? (cont'd) • “Generated mutants are similar to real faults.” • Andrews, Briand, Labiche, ICSE 2005 • “Mutation testing is more powerful than statement or branch coverage.” • Walsh, Ph.D. Thesis, State University of New York at Binghampton, 1985 • “Mutation testing is superior to data flow coverage criteria.” • Frankl, Weiss, Hu, Journal of Systems and Software, 1997
  • 19. 19 © Computas AS 26.01.15 Relation to Other Testing Techniques
  • 20. 20 © Computas AS 26.01.15 Relation to Other Testing Techniques • Unit tests • Test-Driven Development (TDD) • Test coverage • Static code analysis • Fuzz testing
  • 21. 21 © Computas AS 26.01.15 Relation to Other Testing Techniques
  • 22. 22 © Computas AS 26.01.15 Is Mutation Testing New? • R. Lipton, “Fault Diagnosis of Computer Programs,” 1971 • R. Lipton et. al., “Hints on Test Data Selection: Help for the Practicing Programmer,” 1978 • Historical obstacles: • No unit testing • No TDD • Inefficient implementation • Hence time-consuming • No integration with IDEs
  • 23. 23 © Computas AS 26.01.15 Practical Example of Mutation Testing
  • 24. 24 © Computas AS 26.01.15 Code Along… https://github.com/computas-fvl/oop2015 git clone https://github.com/computas-fvl/oop2015.git mvn clean site:site org.pitest:pitest-maven:mutationCoverage
  • 25. 25 © Computas AS 26.01.15 Mutation Testing Techniques
  • 26. 26 © Computas AS 26.01.15 Mutation Testing Techniques • Three aspects: • Mutation injection • Mutation types • Unit test selection per mutant • Key properties: • Efficiency • Performance • Coverage
  • 27. 27 © Computas AS 26.01.15 Mutation Injection • Source code mutation • Intermediate code mutation • Binary code mutation • Caveats: • De-mutation (for reporting) • Compilation errors • Invalid binary code • Leaked state
  • 28. 28 © Computas AS 26.01.15 Mutation Types • Some mutations never change behaviour • Constants reused by unit tests • Log messages • Exception messages • Some mutations can change behaviour • Switching between < and ≠ • Switching between < and ≤ • Some mutations always change behaviour • Switching between < and ≥
  • 29. 29 © Computas AS 26.01.15 Mutation Types (cont'd) int max(int a, int b) { return (a < b) ? b : a; } int max(int a, int b) { return (a <= b) ? b : a; } int max(int a, int b) { return (a >= b) ? b : a; }
  • 30. 30 © Computas AS 26.01.15 Mutation Types (cont'd) for (int i = 0; i < 10; i++) … for (int i = 0; i != 10; i++) … for (int i = 0; i >= 10; i++) …
  • 31. 31 © Computas AS 26.01.15 Mutation Types Guaranteed to Change Behaviour • Negation of the comparison • Switching between = and ≠ • Switching between < and ≥ • Switching between > and ≤ • Negation of boolean conditions • Adding a ¬, ! or ~ • Shortcutting boolean conditions • Replacement with True or False *
  • 32. 32 © Computas AS 26.01.15 Unit Test Selection • Goal: find the unit test that “kills” the mutant • Selection aids: • Hints • Name/package matching • Code coverage tools • Incremental mutation testing • Other heuristics
  • 33. 33 © Computas AS 26.01.15 Unit Test Selection (cont'd) • System: • 50 classes • 20 unit tests per class • 1 ms per unit test • Unit testing time: 50 × 20 × 1ms = 1s • 10 mutants per class: • Brute-force: 10 × 50 × 1s = 6m 20s • Educated: 10 × 50 × 20 × 1ms = 10s
  • 34. 34 © Computas AS 26.01.15 Unit Test Selection (cont'd) • System: • 500 classes • 20 unit tests per class • 1 ms per unit test • Unit testing time: 500 × 20 × 1ms = 10s • 10 mutants per class: • Brute-force: 10 × 500 × 10s = 13h 53m 20s • Educated: 10 × 500 × 20 × 1ms = 1m 40s
  • 35. 35 © Computas AS 26.01.15 Complexity • f: Number of function points • φ: Number of function points per class, ≥ 1 • τ: Number of unit tests per function point, ≥ 1 • μ: Number of mutants per function point, ≥ 1 • Brute-force: (f × τ) × (f × μ) = τ × μ × f² • Educated force: τ × μ × φ × f • Ideal: τ × μ × f
  • 36. 36 © Computas AS 26.01.15 Complexity (cont'd) • c: Number of classes • φ: Number of function points per class, ≥ 1 • τ: Number of unit tests per function point, ≥ 1 • μ: Number of mutants per function point, ≥ 1 • Brute-force: (f × τ) × (f × μ) = τ × μ × φ² × c² • Educated force: τ × μ × φ² × c • Ideal: τ × μ × φ × c
  • 37. 37 © Computas AS 26.01.15 Loops for (int i = 0; i < 10; i++) … for (int i = 0; i < 10; i--) …
  • 38. 38 © Computas AS 26.01.15 Infinite Loops • Terminate mutants that take too long to run • What's “too long”? • Ruins the performance • Can be hard to predict
  • 39. 39 © Computas AS 26.01.15 Other Problems • Recursion: • Stack overflows • Out of memory exceptions • Syntax errors • Leaked state • Segmentation faults
  • 40. 40 © Computas AS 26.01.15 Mutation Testing Tools
  • 41. 41 © Computas AS 26.01.15 Mutation Testing Tools • Java: • PIT • Ruby: • Mutant • Heckle • PHP • Humbug • C#: • NinjaTurtles
  • 42. 42 © Computas AS 26.01.15 PIT • Java • Junit & TestNG • Maven or command-line • Operates on byte code • Large set of mutators • Also possibly equivalent mutators available • Highly configurable • Sensible defaults • http://pitest.org/
  • 43. 43 © Computas AS 26.01.15 PIT Mutators • Conditionals Boundary • Negate Conditionals • Remove Conditionals* • Math • Increments • Invert Negatives • Inline Constant* • Return Values • Void Method Calls • Non Void Method Calls* • Constructor Calls*
  • 44. 44 © Computas AS 26.01.15 PIT Sample Report
  • 45. 45 © Computas AS 26.01.15 Jester • Java • JUnit • Usually run from the command-line • Grester for Maven2 • Operates on source code • Runs all unit tests on all classes • Reporting and documentation could be better • http://jester.sourceforge.net/ • http://sourceforge.net/projects/grester/
  • 46. 46 © Computas AS 26.01.15 Jester Sample Report Overview
  • 47. 47 © Computas AS 26.01.15 Jester Sample Detailed Report
  • 48. 48 © Computas AS 26.01.15 Pester and Nester • Pester • Jester for Python • PyUnit • Nester • Port of Jester for C# • NUnit • Integrated with Visual Studio • But outdated… • http://nester.sourceforge.net/
  • 49. 49 © Computas AS 26.01.15 Nester Sample Report
  • 50. 50 © Computas AS 26.01.15 Jumble • Java • JUnit • Run from the command-line • Operates on byte code • Runs unit tests on a class • Reporting and documentation could be better • Claims to be faster than Jester • http://jumble.sourceforge.net/index.html
  • 51. 51 © Computas AS 26.01.15 Jumble Sample Report Mutating Foo Tests: FooTest Mutation points = 12, unit test time limit 2.02s .. M FAIL: Foo:31: negated conditional M FAIL: Foo:33: negated conditional M FAIL: Foo:34: - -> + M FAIL: Foo:35: negated conditional ...... Score: 67%
  • 52. 52 © Computas AS 26.01.15 Mutant • Ruby 1.9 up to 2.2 • Rspec2 and Rspec3 • Usually run from the command-line • Good to-the-point reporting • Good performance • OK documentation • Active project • https://github.com/mbj/mutant
  • 53. 53 © Computas AS 26.01.15 Heckle • Ruby 1.8 • Doesn't work on Ruby 1.9 • Test::Unit and rSpec • Usually run from the command-line • Runs a set of unit tests on a class or a method • Good to-the-point reporting • Acceptable performance • Virtually no documentation • http://rubyforge.org/projects/seattlerb/ • http://docs.seattlerb.org/heckle/
  • 54. 54 © Computas AS 26.01.15 Heckle Mutations • Booleans • Numbers • Strings • Symbols • Ranges • Regexes • Branches (if, while, unless, until)
  • 55. 55 © Computas AS 26.01.15 Humbug • PHP 5.4 or greater • PHPUnit • Usually run from the command-line • OK documentation • Active project • https://github.com/padraic/humbug
  • 56. 56 © Computas AS 26.01.15 NinjaTurtles • .Net: • C# • Visual Basic/VB.NET • Any other .NET language code • Doesn't seem much alive • http://www.mutation-testing.net/
  • 57. 57 © Computas AS 26.01.15 NinjaTurtles Mutations • Sequence point deletion • Arithmetic operator substitution (*, /, +, -, %) • Bitwise operator substitution (&, |, ^) • Branch substituion (condition, always and never branch) • Conditional boundary substition (< and <=, > and >=) • Substitution of reads from variables, parameters and fields of the same type • Substitution of writes to variables of the same type
  • 58. 58 © Computas AS 26.01.15 Personal Experiences and Recommendations
  • 59. 59 © Computas AS 26.01.15 Experiences and Recommendations • Use mutation testing from day 1 • Start on a small code base • Keep things simple • Have small interfaces • Select a good tool • Configurable • Flexible • One that can output the mutant
  • 60. 60 © Computas AS 26.01.15 Experiences and Recommendations (cont'd) • Believe the tool • Or try to proof that the tool is wrong • Fix the problem • Don't turn mutation testing off • Embrace the “more than 100%” test coverage • Semantic coverage • Less code • More unit tests • More intelligent unit tests
  • 61. 61 © Computas AS 26.01.15 Improvements
  • 62. 62 © Computas AS 26.01.15 Improvements • Integration with more unit testing frameworks • Better unit test–source code mapping • Better heuristics • Parallellisation • Better reporting • IDE integration • Building tool integration