SlideShare a Scribd company logo
Submit Search
Upload
Login
Signup
Oop 2015 – Mutation Testing
Report
Filip Van Laenen
Follow
Sjefsarkitekt/Chief Architect at Computas AS
Jan. 26, 2015
•
0 likes
•
1,140 views
1
of
62
Oop 2015 – Mutation Testing
Jan. 26, 2015
•
0 likes
•
1,140 views
Download Now
Download to read offline
Report
Software
Filip Van Laenen
Follow
Sjefsarkitekt/Chief Architect at Computas AS
Recommended
Mutation Testing with PIT (Booster 2014, 2014-MAR-13)
Filip Van Laenen
1.5K views
•
62 slides
Kill the mutants and test your tests - Roy van Rijn
NLJUG
1.5K views
•
55 slides
Kill the mutants - A better way to test your tests
Roy van Rijn
9K views
•
55 slides
TMPA-2017: Regression Testing with Semiautomatic Test Selection for Auditing ...
Iosif Itkin
766 views
•
11 slides
TMPA-2017: 5W+1H Static Analysis Report Quality Measure
Iosif Itkin
1.1K views
•
33 slides
Joker - Improve your tests with mutation testing
Nicolas Frankel
1.3K views
•
55 slides
More Related Content
Viewers also liked
Mutation testing
Raúl Ávila
1.1K views
•
16 slides
GeeCON - Improve your tests with Mutation Testing
Nicolas Frankel
1.8K views
•
63 slides
MUTANTS KILLER (Revised) - PIT: state of the art of mutation testing system
Tarin Gamberini
2.1K views
•
59 slides
Mutation Testing
ESUG
9.9K views
•
45 slides
Javantura v3 - Mutation Testing for everyone – Nicolas Fränkel
HUJAK - Hrvatska udruga Java korisnika / Croatian Java User Association
2.2K views
•
62 slides
Mutation testing
Tao He
3K views
•
33 slides
Viewers also liked
(6)
Mutation testing
Raúl Ávila
•
1.1K views
GeeCON - Improve your tests with Mutation Testing
Nicolas Frankel
•
1.8K views
MUTANTS KILLER (Revised) - PIT: state of the art of mutation testing system
Tarin Gamberini
•
2.1K views
Mutation Testing
ESUG
•
9.9K views
Javantura v3 - Mutation Testing for everyone – Nicolas Fränkel
HUJAK - Hrvatska udruga Java korisnika / Croatian Java User Association
•
2.2K views
Mutation testing
Tao He
•
3K views
Similar to Oop 2015 – Mutation Testing
How good are your tests?
Noam Shaish
259 views
•
28 slides
Effective Test Suites for ! Mixed Discrete-Continuous Stateflow Controllers
Lionel Briand
458 views
•
48 slides
SSBSE 2020 keynote
Shiva Nejati
412 views
•
89 slides
Testing of Cyber-Physical Systems: Diversity-driven Strategies
Lionel Briand
359 views
•
41 slides
SAST, fight against potential vulnerabilities
Andrey Karpov
119 views
•
40 slides
Unit testing basics
João Paulo Leonidas Fernandes Dias da Silva
385 views
•
29 slides
Similar to Oop 2015 – Mutation Testing
(20)
How good are your tests?
Noam Shaish
•
259 views
Effective Test Suites for ! Mixed Discrete-Continuous Stateflow Controllers
Lionel Briand
•
458 views
SSBSE 2020 keynote
Shiva Nejati
•
412 views
Testing of Cyber-Physical Systems: Diversity-driven Strategies
Lionel Briand
•
359 views
SAST, fight against potential vulnerabilities
Andrey Karpov
•
119 views
Unit testing basics
João Paulo Leonidas Fernandes Dias da Silva
•
385 views
Automatic Test Pattern Generation (Testing of VLSI Design)
Usha Mehta
•
1.2K views
Mike Bartley - Innovations for Testing Parallel Software - EuroSTAR 2012
TEST Huddle
•
388 views
Dealing with the Three Horrible Problems in Verification
DVClub
•
700 views
Chapter 14 software testing techniques
SHREEHARI WADAWADAGI
•
1.4K views
Evaluating Model Testing and Model Checking for Finding Requirements Violatio...
Lionel Briand
•
447 views
Qt test framework
ICS
•
10.1K views
Automated Testing of Hybrid Simulink/Stateflow Controllers
Lionel Briand
•
1.2K views
Testing Dynamic Behavior in Executable Software Models - Making Cyber-physica...
Lionel Briand
•
955 views
Shift-Left Testing: QA in a DevOps World by David Laulusa
QA or the Highway
•
255 views
Mutation testing (OOP 2012, 2012-JAN-24)
Filip Van Laenen
•
3.3K views
SOFTWARE TESTING W4_watermark.pdf
GayathriRHICETCSESTA
•
56 views
Automated testing of ASP .Net Core applications
nispas
•
34 views
Automated and Scalable Solutions for Software Testing: The Essential Role of ...
Lionel Briand
•
345 views
11 whiteboxtesting
asifusman1998
•
1.4K views
More from Filip Van Laenen
Drawing for IT Architects
Filip Van Laenen
263 views
•
156 slides
How JSR 385 could have saved the Mars Climate Orbiter
Filip Van Laenen
495 views
•
65 slides
How JSR-385 Could Have Saved the Mars Climate Orbiter
Filip Van Laenen
369 views
•
56 slides
Clouds with Trenches and Sharp Edges
Filip Van Laenen
263 views
•
46 slides
Become an SVG Architect, not a PowerPoint Architect
Filip Van Laenen
251 views
•
15 slides
Dial M for Mutation
Filip Van Laenen
225 views
•
99 slides
More from Filip Van Laenen
(17)
Drawing for IT Architects
Filip Van Laenen
•
263 views
How JSR 385 could have saved the Mars Climate Orbiter
Filip Van Laenen
•
495 views
How JSR-385 Could Have Saved the Mars Climate Orbiter
Filip Van Laenen
•
369 views
Clouds with Trenches and Sharp Edges
Filip Van Laenen
•
263 views
Become an SVG Architect, not a PowerPoint Architect
Filip Van Laenen
•
251 views
Dial M for Mutation
Filip Van Laenen
•
225 views
Mutasjonstesting – Lag bugs for å få bedre kode
Filip Van Laenen
•
445 views
Hvem kommer til å vinne kommunevalget?
Filip Van Laenen
•
600 views
Five Inconvenient Truths about REST
Filip Van Laenen
•
613 views
How Free Data Can Drive Some of the Monkey Business Out of Political Journali...
Filip Van Laenen
•
586 views
#NoEstimates – Smidig 2014
Filip Van Laenen
•
513 views
#NoEstimates – Javazone 2014
Filip Van Laenen
•
1.1K views
Tre ubeleilige sannheter om REST
Filip Van Laenen
•
368 views
What Architects Really Do
Filip Van Laenen
•
941 views
Hvorfor stole på e-valg 2011/13?
Filip Van Laenen
•
681 views
SVG (Devoxx 2011, 2011-NOV-14)
Filip Van Laenen
•
600 views
SVG (Framsia, 27-SEP-2011)
Filip Van Laenen
•
488 views
Recently uploaded
The Future of AI-Based Test Automation
Applitools
39 views
•
39 slides
Endlich gute API Tests. Boldly Testing APIs Where No One Has Tested Before.
QAware GmbH
15 views
•
57 slides
Microsoft Graph Powershell, gestire vecchi problemi con una mentalità nuova....
Giuliano Latini
6 views
•
45 slides
Cloud Powered Dynamo for Dynamics 365 FO Payroll Management Improves Efficien...
Dynamics Business Solutions
17 views
•
10 slides
Expo - Zero to App.pptx
😎 Anthony Kariuki
14 views
•
28 slides
COA.pptx
GoluTiwari22
13 views
•
14 slides
Recently uploaded
(20)
The Future of AI-Based Test Automation
Applitools
•
39 views
Endlich gute API Tests. Boldly Testing APIs Where No One Has Tested Before.
QAware GmbH
•
15 views
Microsoft Graph Powershell, gestire vecchi problemi con una mentalità nuova....
Giuliano Latini
•
6 views
Cloud Powered Dynamo for Dynamics 365 FO Payroll Management Improves Efficien...
Dynamics Business Solutions
•
17 views
Expo - Zero to App.pptx
😎 Anthony Kariuki
•
14 views
COA.pptx
GoluTiwari22
•
13 views
Payroll Automation Benefits and Challenges
HRMantra Software Pvt. Ltd
•
6 views
From Code to Cosmos: Mastering Microservices in the Distributed Wonderland
Bogdan Sucaciu
•
14 views
The Chalice of the Gods (Percy Jackson and the Olympians, #6)
YvonneDTurner
•
6 views
Road to NODES 2023: Graphing Relational Databases
Neo4j
•
65 views
Five years of self-selection reteaming at Redgate - Agile Cambridge 2023
Chris Smith
•
32 views
AWS Developer Ecosystem.pdf
Dhaval Nagar
•
15 views
BMC Software.pptx
Cloudaction
•
14 views
Workflow Engines & Event Streaming Brokers - Can they work together? [Current...
Natan Silnitsky
•
150 views
Co-creating with UX and Software Rabobank
SimonedeGijt
•
22 views
CoC23_Utilizing Real-Time Transit Data for Travel Optimization
Timothy Spann
•
5 views
Databricks IPO-Revolutionizing Data with Cutting-Edge Technology
My Gen Tec
•
5 views
DTOs in Laravel - Why and How
Wendell Adriel
•
49 views
Navigating Disaster Recovery in Kubernetes and CNCF Crossplane
Carlos Santana
•
16 views
The Never Landing Stream with HTAP and Streaming
Timothy Spann
•
201 views
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