SlideShare a Scribd company logo
Intro to Mutation Testing (CON 1694)
slideshare.net/boyarsky
Twitter @jeanneboyarsky
Blog: http://www.selikoff.net
Jeanne Boyarsky
JavaOne - October 5, 2017
@jeanneboyarsky
About Me
15 years as
•Java Developer
•JUnit user
The Plan
1. About mutation testing
2. Live demo
3. A look at types of mutants
4. Profit???
@jeanneboyarsky
Why write tests?
@jeanneboyarsky
It used to
work!
How know if tests are good?
@jeanneboyarsky
If test coverage low
@jeanneboyarsky
Write more tests!
Not ready
for mutation
testing of class
If test coverage high
@jeanneboyarsky
All done!
Perfect code!
Or is it?Why is it
saying
nobody is
registered?
@jeanneboyarsky
Code Review!
@jeanneboyarsky
That’s a mutant!
@jeanneboyarsky
Too many mutants!
They’re
everywhere!
@jeanneboyarsky
PitClipse to the rescue!
@jeanneboyarsky
@jeanneboyarsky
PIT Integration Almost
JUnit 5
• Unofficial Fork:
https://github.com/tobiasstadler/pitest-junit5-plugin
• It’s coming:
https://github.com/hcoles/pitest/issues/284
https://github.com/hcoles/pitest/issues/398
@jeanneboyarsky
Easy to run
@jeanneboyarsky
The console flies by
@jeanneboyarsky
Wait, we just had 100% coverage
@jeanneboyarsky
We caught 5 mutants
@jeanneboyarsky
More detail
@jeanneboyarsky
Level up
@jeanneboyarsky
Now 23 survived
@jeanneboyarsky
Let’s try it!
@jeanneboyarsky
Observations
• JUnit tests must pass
• Fixing one may take care of more
• Found a bug
• Better tests
@jeanneboyarsky
Now with all mutators
@jeanneboyarsky
Observations
• Better tests
• Unused production code
@jeanneboyarsky
Examples of Conditional Mutants
@jeanneboyarsky
Conditionals Boundary <= vs <
Negative Conditionals <= vs >
Void Method Call Removes method calls
Examples of Math Mutants
@jeanneboyarsky
Math * vs /
Increments ++ vs --
Invert Negatives x vs -x
Examples of Other Mutants
@jeanneboyarsky
Return Values x vs x+1
Disabled by default (false
positives, duplicates or
crashes)
Constructor Calls
Inline Constants
Non Void Method Calls
Remove Conditionals
Experimental Member Variables
Switch
Tips for bigger projects
• Watch console to see if still running
• Reports on whole project – drill down/split up
• Exclude long running tests
• Experimental feature: incremental analysis
@jeanneboyarsky
Review
Code Coverage
Mutation Testing
Requirements
More info
• http://pitest.org/
• https://github.com/philglover/pitclipse
• https://dzone.com/articles/introduction-mutation
@jeanneboyarsky
@jeanneboyarsky

More Related Content

PDF
G*Magazineを読もう
PDF
Xamarin essentials un API cross-platform para gobernarlos a todos
PDF
Agnostic agile: Lunch and Learn BJSS Leeds
PPTX
LAB - How to Git
PDF
My journey discovering Agnostic Agile
PDF
"Discovering Agnostic Agile" - Agile Tour Brussels 2018
PPT
2016 java-sig-mutation-testing
G*Magazineを読もう
Xamarin essentials un API cross-platform para gobernarlos a todos
Agnostic agile: Lunch and Learn BJSS Leeds
LAB - How to Git
My journey discovering Agnostic Agile
"Discovering Agnostic Agile" - Agile Tour Brussels 2018
2016 java-sig-mutation-testing

Similar to 2017 JavaOne Mutation Testing Session (13)

PPTX
2016 first-champs-java-cert
PDF
IACT-TAP New School Thinking - Prototype Workshop
PPTX
Vivien Ibironke Ibiyemi. Comaqa Spring 2018. Enhance your Testing Skills With...
PDF
Paving roads
PPTX
Claudiu Draghia ITEM 2018
PPTX
10 Ways Everyone Can Support the Java Community
PDF
Software development in a startup
PDF
Doonish
PDF
Doonish
PDF
Git intro fajar muslim
PPTX
Python Hype June
PDF
Dev Nexus 2017 - TDD with React - Josh Quintana & Tom Gamble
PPTX
Spaceship TDD Style
2016 first-champs-java-cert
IACT-TAP New School Thinking - Prototype Workshop
Vivien Ibironke Ibiyemi. Comaqa Spring 2018. Enhance your Testing Skills With...
Paving roads
Claudiu Draghia ITEM 2018
10 Ways Everyone Can Support the Java Community
Software development in a startup
Doonish
Doonish
Git intro fajar muslim
Python Hype June
Dev Nexus 2017 - TDD with React - Josh Quintana & Tom Gamble
Spaceship TDD Style
Ad

More from Jeanne Boyarsky (19)

PPTX
Pathways intro january 2018
PPTX
Pathways path-comparison
PPT
2017 stuysplash-build-tools
PPTX
Virtual scrum
PPTX
Ignite java-robots
PPT
java 8 Hands on Workshop
PPT
2017 java9-spring-days
PPTX
Pathways overview
PPT
Ftc judging
PPT
2016 qcon-virtual-scrum
PPT
2016 java9-how-make-qus
PPT
2016 java9-how-make-qus
PPT
2016 java8-cert-intro
PPT
FTC 2015-2016 Judging
PPT
2015 nyc-spin-collective-ownership
PPT
FTC Robot C to Java
PPT
Frc java5-8andeclipse
PPT
Throw Away all the Rules: Now What Process do you Follow?
PPT
Get ready for FRC 2015: Intro to Java 5 through 8 updates and Eclipse
Pathways intro january 2018
Pathways path-comparison
2017 stuysplash-build-tools
Virtual scrum
Ignite java-robots
java 8 Hands on Workshop
2017 java9-spring-days
Pathways overview
Ftc judging
2016 qcon-virtual-scrum
2016 java9-how-make-qus
2016 java9-how-make-qus
2016 java8-cert-intro
FTC 2015-2016 Judging
2015 nyc-spin-collective-ownership
FTC Robot C to Java
Frc java5-8andeclipse
Throw Away all the Rules: Now What Process do you Follow?
Get ready for FRC 2015: Intro to Java 5 through 8 updates and Eclipse
Ad

Recently uploaded (20)

DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
A comparative analysis of optical character recognition models for extracting...
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PPTX
A Presentation on Artificial Intelligence
PPTX
Cloud computing and distributed systems.
PPT
Teaching material agriculture food technology
PDF
cuic standard and advanced reporting.pdf
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
The AUB Centre for AI in Media Proposal.docx
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Programs and apps: productivity, graphics, security and other tools
A comparative analysis of optical character recognition models for extracting...
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Mobile App Security Testing_ A Comprehensive Guide.pdf
MIND Revenue Release Quarter 2 2025 Press Release
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Review of recent advances in non-invasive hemoglobin estimation
Diabetes mellitus diagnosis method based random forest with bat algorithm
gpt5_lecture_notes_comprehensive_20250812015547.pdf
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
A Presentation on Artificial Intelligence
Cloud computing and distributed systems.
Teaching material agriculture food technology
cuic standard and advanced reporting.pdf
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf

2017 JavaOne Mutation Testing Session

Editor's Notes

  • #4: https://cdn.pixabay.com/photo/2012/05/07/05/18/bug-48020_1280.png https://pixabay.com/p-303966/?no_redirect
  • #5: https://cdn.pixabay.com/photo/2012/05/07/05/18/bug-48020_1280.png https://pixabay.com/p-303966/?no_redirect
  • #6: http://www.eclemma.org/jacoco/trunk/coverage/
  • #7: https://pixabay.com/p-149251/?no_redirect
  • #9: https://pixabay.com/p-1300226/?no_redirect
  • #11: http://www.publicdomainpictures.net/pictures/180000/velka/mutant-female-41.jpg
  • #12: http://orig01.deviantart.net/920f/f/2015/013/a/8/teenage_mutant_ninja_turtles__2003__drawing__by_n0rvv3g14n_g1rl-d8drynd.jpg
  • #14: Image sources: https://commons.wikimedia.org/wiki/File:Antu_netbeans-ide.svg https://commons.wikimedia.org/wiki/File:Eclipse-SVG.svg https://commons.wikimedia.org/wiki/File:IntelliJ_IDEA_Logo.svg https://ant.apache.org https://maven.apache.org http://junit.org/junit4/
  • #23: Run initially Add 2 assertTrue and one assertFalse on tooManyAttendees – incorrectly to show failure with failing unit tests. Wait there’s a bug. Fix assertions and see down to three mutants In cancel test assertFalse on my registration now down to two mutants Then add assertTrue on Barry’s registration and see all mutants killed
  • #25: Change to all mutators Run initially and note that down from 23 to 7 – our tests are better Note that the wait list logic still isn’t tested enough. Add test for jeanne and maurice cancelling with barry and sai on wait list with four asserts 4 mutants left Add test for sai not on wait list so wait list empty 2 mutants left These two are interesting as they point to unused code – isRoomForMoreAttendees always true and don’t use company name (attendee map value)
  • #33: https://commons.wikimedia.org/wiki/File:Online_Survey_Icon_or_logo.svg