$30 off During Our Annual Pro Sale. View Details »
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
97
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
実は歴史的なアップデートだと思う AWS Interconnect - multicloud
maroon1st
0
120
まだ間に合う!Claude Code元年をふりかえる
nogu66
5
830
Developing static sites with Ruby
okuramasafumi
0
290
愛される翻訳の秘訣
kishikawakatsumi
3
320
AIコーディングエージェント(NotebookLM)
kondai24
0
190
안드로이드 9년차 개발자, 프론트엔드 주니어로 커리어 리셋하기
maryang
1
110
俺流レスポンシブコーディング 2025
tak_dcxi
14
8.7k
開発に寄りそう自動テストの実現
goyoki
2
960
React Native New Architecture 移行実践報告
taminif
1
150
認証・認可の基本を学ぼう前編
kouyuume
0
200
sbt 2
xuwei_k
0
300
How Software Deployment tools have changed in the past 20 years
geshan
0
29k
Featured
See All Featured
Large-scale JavaScript Application Architecture
addyosmani
515
110k
[SF Ruby Conf 2025] Rails X
palkan
0
510
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
Statistics for Hackers
jakevdp
799
230k
Agile that works and the tools we love
rasmusluckow
331
21k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
249
1.3M
Building Better People: How to give real-time feedback that sticks.
wjessup
370
20k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
2.7k
YesSQL, Process and Tooling at Scale
rocio
174
15k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
12
970
Git: the NoSQL Database
bkeepers
PRO
432
66k
Designing Experiences People Love
moore
143
24k
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