Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Intro to Mutation Testing
Search
Jeanne Boyarsky
March 05, 2018
Technology
1
110
Intro to Mutation Testing
Presented at Oracle Code NYC 2018. This is a repeat of the session I gave at JavaOne in 2017.
Jeanne Boyarsky
March 05, 2018
Tweet
Share
More Decks by Jeanne Boyarsky
See All by Jeanne Boyarsky
2025 FRC Changes and Awards - NYC FIRST
boyarsky
0
30
Managing Your Time for Work, Learning, and Fun
boyarsky
0
63
Preparing for the Java 21 Certification and Learning New Features
boyarsky
0
180
2024-java21.pdf
boyarsky
0
47
NYC FRC 2024 Kickoff Awards Presentation
boyarsky
0
96
Preparing to Apply and Speak at Conferences
boyarsky
0
65
Refactoring to Java 21
boyarsky
1
99
2023-static-analysis.pdf
boyarsky
0
85
Readable Regular Expressions in Java
boyarsky
0
180
Other Decks in Technology
See All in Technology
【Developers Summit 2025】プロダクトエンジニアから学ぶ、 ユーザーにより高い価値を届ける技術
niwatakeru
2
1.4k
2.5Dモデルのすべて
yu4u
2
870
目の前の仕事と向き合うことで成長できる - 仕事とスキルを広げる / Every little bit counts
soudai
24
7.2k
Building Products in the LLM Era
ymatsuwitter
10
5.5k
地方拠点で エンジニアリングマネージャーってできるの? 〜地方という制約を楽しむオーナーシップとコミュニティ作り〜
1coin
1
230
転生CISOサバイバル・ガイド / CISO Career Transition Survival Guide
kanny
3
1k
Raycast AI APIを使ってちょっと便利な拡張機能を作ってみた / created-a-handy-extension-using-the-raycast-ai-api
kawamataryo
0
100
プロダクトエンジニア構想を立ち上げ、プロダクト志向な組織への成長を続けている話 / grow into a product-oriented organization
hiro_torii
1
220
Goで作って学ぶWebSocket
ryuichi1208
2
1.3k
ホワイトボードチャレンジ 説明&実行資料
ichimichi
0
130
人はなぜISUCONに夢中になるのか
kakehashi
PRO
6
1.7k
君も受託系GISエンジニアにならないか
sudataka
2
440
Featured
See All Featured
jQuery: Nuts, Bolts and Bling
dougneiner
63
7.6k
A designer walks into a library…
pauljervisheath
205
24k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
27
1.6k
Optimizing for Happiness
mojombo
376
70k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
30
4.6k
Designing on Purpose - Digital PM Summit 2013
jponch
117
7.1k
Being A Developer After 40
akosma
89
590k
Site-Speed That Sticks
csswizardry
4
380
Rails Girls Zürich Keynote
gr2m
94
13k
Designing for humans not robots
tammielis
250
25k
Building a Modern Day E-commerce SEO Strategy
aleyda
38
7.1k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
30
2.2k
Transcript
Intro to Mutation Testing speakerdeck.com/boyarsky Twitter @jeanneboyarsky Blog: http://www.selikoff.net Jeanne
Boyarsky Oracle Code NYC – March 8, 2018
@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