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
120
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
Beyond JUnit 5
boyarsky
0
19
Java 21 Certification (or learning new features)
boyarsky
0
34
Preparing for the Java 21 cert + Learning New Features
boyarsky
0
170
Mastering Logging in Java
boyarsky
0
120
2025 FRC Changes and Awards - NYC FIRST
boyarsky
0
71
Managing Your Time for Work, Learning, and Fun
boyarsky
0
120
Preparing for the Java 21 Certification and Learning New Features
boyarsky
0
250
2024-java21.pdf
boyarsky
0
92
NYC FRC 2024 Kickoff Awards Presentation
boyarsky
0
110
Other Decks in Technology
See All in Technology
進捗
ydah
2
230
【初心者向け】ローカルLLMの色々な動かし方まとめ
aratako
4
2.6k
実践アプリケーション設計 ①データモデルとドメインモデル
recruitengineers
PRO
5
1.4k
新規案件の立ち上げ専門チームから見たAI駆動開発の始め方
shuyakinjo
0
650
JuniorからSeniorまで: DevOpsエンジニアの成長ロードマップ
yuriemori
2
350
異業種出身エンジニアが気づいた、転向して十数年経っても変わらない自分の武器とは
macnekoayu
0
260
ヒューリスティック評価を用いたゲームQA実践事例
gree_tech
PRO
0
430
Function Body Macros で、SwiftUI の View に Accessibility Identifier を自動付与する/Function Body Macros: Autogenerate accessibility identifiers for SwiftUI Views
miichan
2
150
退屈なことはDevinにやらせよう〜〜Devin APIを使ったVisual Regression Testの自動追加〜
kawamataryo
4
1.1k
実践データベース設計 ①データベース設計概論
recruitengineers
PRO
4
2k
Kiroと学ぶコンテキストエンジニアリング
oikon48
5
6.7k
スプリントレトロスペクティブはチーム観察の宝庫? 〜チームの衝突レベルに合わせたアプローチ仮説!〜
electricsatie
1
150
Featured
See All Featured
Designing for humans not robots
tammielis
253
25k
Optimising Largest Contentful Paint
csswizardry
37
3.4k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
358
30k
Unsuck your backbone
ammeep
671
58k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
51
5.6k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
34
6k
Code Reviewing Like a Champion
maltzj
525
40k
What's in a price? How to price your products and services
michaelherold
246
12k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
23
1.4k
Testing 201, or: Great Expectations
jmmastey
45
7.6k
Fashionably flexible responsive web design (full day workshop)
malarkey
407
66k
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