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
100
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
Preparing for the Java 21 Certification and Learning New Features
boyarsky
0
64
2024-java21.pdf
boyarsky
0
16
NYC FRC 2024 Kickoff Awards Presentation
boyarsky
0
53
Preparing to Apply and Speak at Conferences
boyarsky
0
37
Refactoring to Java 21
boyarsky
1
28
2023-static-analysis.pdf
boyarsky
0
32
Readable Regular Expressions in Java
boyarsky
0
85
Readable Regular Expressions
boyarsky
0
170
Java Idioms for becoming a more powerful developer
boyarsky
0
130
Other Decks in Technology
See All in Technology
KubeConにproposalを送りたい人へのアドバイス
sat
PRO
3
250
Yahoo! 知恵袋フロントエンドをリアーキテクトしている話
lycorptech_jp
PRO
1
100
GraphQL 成熟度モデルの紹介と、プロダクトに当てはめた事例 / GraphQL maturity model
mh4gf
7
1.3k
ワールドカフェI /チューターを改良する / World Café I and Improving the Tutors
ks91
PRO
0
120
ExaDB-D dbaascli で出来ること
oracle4engineer
PRO
0
2.1k
長期間TiDBを使ってきた話 @ 私たちはなぜNewSQLを使うのかTiDB選定5社が語る選定理由と活用LT / Experiences with TiDB Over Time
chibiegg
2
890
Azure Container Apps + Bicep 〜 こんな感じで運用しています
kaz29
2
470
Compose Compiler Metricsを使った実践的なコードレビュー
tomorrowkey
1
220
「スニダン」開発組織の構造に込めた意図 ~組織作りはパッションや政治ではない!~
rinchsan
3
550
Meta Quest 3 で動く桜マシマシ WebXR アプリを IBM Cloud Code Engine と Babylon.js で作った話
1ftseabass
PRO
0
120
アクセシビリティを考慮したUI/CSSフレームワーク・ライブラリ選定
yajihum
2
1k
リテール金融(キャッシュレス・ネット銀行・ネット証券)の競争環境と経済圏
8maki
0
910
Featured
See All Featured
Understanding Cognitive Biases in Performance Measurement
bluesmoon
7
1k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
155
14k
Atom: Resistance is Futile
akmur
259
25k
Ruby is Unlike a Banana
tanoku
96
10k
It's Worth the Effort
3n
180
27k
A Tale of Four Properties
chriscoyier
151
22k
The Language of Interfaces
destraynor
151
23k
Optimising Largest Contentful Paint
csswizardry
8
2.4k
Stop Working from a Prison Cell
hatefulcrawdad
266
19k
Gamification - CAS2011
davidbonilla
76
4.6k
A designer walks into a library…
pauljervisheath
200
23k
The Cult of Friendly URLs
andyhume
74
5.7k
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