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
Eeek, my tests are mutating
Search
Lander Vanderstraeten
November 07, 2017
Programming
1
93
Eeek, my tests are mutating
Presentation given for
https://www.meetup.com/phpgent/events/242279704
Lander Vanderstraeten
November 07, 2017
Tweet
Share
Other Decks in Programming
See All in Programming
タイムゾーンの奥地は思ったよりも闇深いかもしれない
suguruooki
1
570
これだけは知っておきたいクラス設計の基礎知識 version 2
masuda220
PRO
24
6.1k
Memory API : Patterns, Performance et Cas d'Utilisation
josepaumard
0
110
サービスクラスのありがたみを発見したときの思い出 #phpcon_odawara
77web
4
630
ベクトル検索システムの気持ち
monochromegane
31
9.9k
Deoptimization: How YJIT Speeds Up Ruby by Slowing Down / RubyKaigi 2025
k0kubun
0
500
Youtube Lofier - Chrome拡張開発
ninikoko
0
2.4k
custom_lintで始めるチームルール管理
akaboshinit
0
200
PHPバージョンアップから始めるOSSコントリビュート / how2oss-contribute
dmnlk
1
990
Unlock the Potential of Swift Code Generation
rockname
0
240
小田原でみんなで一句詠みたいな #phpcon_odawara
stefafafan
0
320
新しいPHP拡張モジュールインストール方法「PHP Installer for Extensions (PIE)」を使ってみよう!
cocoeyes02
0
340
Featured
See All Featured
What's in a price? How to price your products and services
michaelherold
245
12k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
30
2.3k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
13
1.4k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
5
520
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
29
9.4k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
41
2.2k
Rails Girls Zürich Keynote
gr2m
94
13k
Writing Fast Ruby
sferik
628
61k
Rebuilding a faster, lazier Slack
samanthasiow
80
8.9k
How to train your dragon (web standard)
notwaldorf
91
6k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
9
740
Designing for Performance
lara
607
69k
Transcript
HI, I'M LANDER VANDERSTRAETEN 1
3 QUIZ QUESTIONS 2
WHO THINKS UNIT TESTS ARE WASTE OF TIME? 3
4
WHO ALWAYS WRITES UNIT TESTS? 5
6
WHO ALREADY USES MUTATION TESTING? 7
8
CODE HAS BUGS TESTS ARE CODE TESTS HAVE BUGS! 9
10
TESTS ARE A GOOD TOOL TO VERIFY YOUR CODE BUT
HOW DO YOU VERIFY YOUR TESTS? 11
CODE COVERAGE IS A START, BUT IT CAN GIVE A
“GOOD” SCORE WITH USELESS TESTS 12
ALL TESTS PASSED! 13
HOW WE DETECT? 14
MUTATION TESTING 15
Mutation testing is a technique to evaluate the quality of
your tests by programmatically mutating and making a series of small modifications to your code so that the tests no longer pass. 16
17
IF BUGS ARE CRIMES AND YOUR TESTS ARE THE POLICE
MUTATIONS ARE FAKE CRIMES THAT LET YOU SEE THE POLICE IS DOING THEIR JOB 18
TO ASSESS THE QUALITY OF A GIVEN TEST, MUTANTS ARE
EXECUTED AGAINST THE INPUT TEST TO SEE IF THE SEEDED FAULTS CAN BE DETECTED. 19
MUTATION, MUTANTS, MUTAFUCK WHAT? 20
Each mutated version: Mutant Mutated program + failing tests: killed
mutant Mutated program + passed tests: escaped mutant 21
MEASURE ALL THE THINGS! 22
Test suites are measured by the percentage of mutants that
they kill. New tests can be designed to kill additional mutants. 23
HOW DOES IT MODIFY? 24
MUTATORS 25
EXAMPLE public function foobar(int $number): int { return $number +
1; // original } public function foobar(int $number): int { return $number - 1; // mutated version } 26
ANOTHER EXAMPLE public function foobar(?Bar $foo): string { if (null
=== $foo) { // original return 'foo'; } // ... } public function foobar(?Bar $foo): string { if (null !== $foo) { // mutated version return 'foo'; } // ... } 27
DEMO TIME WITH INFECTION 28
WHAT DID WE LEARN TODAY? 29
1. Always write unit tests 2. Code coverage gives a
false positive feeling 3. Mutation testing also gives a false positive feeling 30
QUESTIONS? 31