armakuni.com
Mutation
Testing
Berlin PHP UG
Billie Thompson
Slide 2
Slide 2 text
About me
2
● Consulting Engineer for Armakuni
● I help “Return creativity & joy to the
world of software engineering”
● Quite tall
● Favourite animal is the capybara
Slide 3
Slide 3 text
We’ve worked with
3
Slide 4
Slide 4 text
What is it?
Break your
code
Ensure a
test fails
Improve
test
4
Slide 5
Slide 5 text
Warm-up
Slide 6
Slide 6 text
Do you all know your TDD Cycle
Red Green Refactor Red
6
Slide 7
Slide 7 text
Todo list ●
7
● TDD
● Demo: When the test doesn’t fail
● When it’s useful
● Demo: Infection
Slide 8
Slide 8 text
TDD
8
Slide 9
Slide 9 text
Red
9
Slide 10
Slide 10 text
Green
10
Slide 11
Slide 11 text
Refactor
11
Slide 12
Slide 12 text
Red
12
Slide 13
Slide 13 text
Demo: Break It
Slide 14
Slide 14 text
What happens if the tests pass?
14
Slide 15
Slide 15 text
Bowling
15
Slide 16
Slide 16 text
Bowling
16
Slide 17
Slide 17 text
10 Pins
17
Slide 18
Slide 18 text
10 sets of up to 2 rolls
18
Slide 19
Slide 19 text
A score card
1 2 3 4 5 6 7 8 9 10
19
Slide 20
Slide 20 text
Rules: Standard
Set 1 Set 2
Roll 1 Roll 2 Roll 1 Roll 2
Pins 1 1 1 1
Score 1 2 3 4
20
Slide 21
Slide 21 text
Rules: Spare
Set 1 Set 2
Roll 1 Roll 2 Roll 1 Roll 2
Pins 5 5 1 1
Score 5 10 12 13
21
Slide 22
Slide 22 text
Rules: Strike
Set 1 Set 2
Roll 1 Roll 2 Roll 1 Roll 2
Pins 10 1 1
Score 10 12 14
22
Slide 23
Slide 23 text
Demo: Break It
Slide 24
Slide 24 text
No content
Slide 25
Slide 25 text
What is it?
Break your
code
Ensure a
test fails
Improve
test
25
Slide 26
Slide 26 text
Step by Step
Build AST
Introduce
Bug
Do Tests
Fail?
26
Slide 27
Slide 27 text
Step by Step
Build AST
Introduce
Bug
Do Tests
Fail?
Introduce
Bug
Do Tests
Fail?
Introduce
Bug
Do Tests
Fail?
27
Slide 28
Slide 28 text
28
Infection has 134 ways
to break your code
Slide 29
Slide 29 text
Todo list ●
29
✓ TDD
✓ Demo: When the test doesn’t fail
● When it’s useful
● Demo: Infection
Slide 30
Slide 30 text
Stefan has inherited a codebase
30
Slide 31
Slide 31 text
What bad habit does Stefan have?
31
Slide 32
Slide 32 text
Bugs keep appearing
32
Slide 33
Slide 33 text
Stefan gets stricter with reviews
33
Slide 34
Slide 34 text
Find untested code
34
Slide 35
Slide 35 text
Other Use Cases ●
35
● Open Source Projects
● New languages
● Improving your heuristic toolkit
Slide 36
Slide 36 text
Todo list ●
36
✓ TDD
✓ Demo: When the test doesn’t fail
✓ When it’s useful
● Demo: Infection