Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Speaker Deck
PRO
Sign in
Sign up
for free
Snapshot testing (nomadphp)
Freek Van der Herten
July 20, 2017
Technology
0
52
Snapshot testing (nomadphp)
Freek Van der Herten
July 20, 2017
Tweet
Share
More Decks by Freek Van der Herten
See All by Freek Van der Herten
freekmurze
0
72
freekmurze
0
260
freekmurze
1
380
freekmurze
1
190
freekmurze
0
350
freekmurze
0
110
freekmurze
1
320
freekmurze
0
320
freekmurze
0
100
Other Decks in Technology
See All in Technology
syoshie
0
490
oliva
7
1.2k
110y
1
11k
imdigitallab
0
490
pakio
0
130
mahito
0
230
yuzutas0
8
3k
gamella
3
1.5k
tricknotes
0
120
karamem0
1
770
eller86
1
230
yunoda
0
130
Featured
See All Featured
jcasabona
8
550
davidbonilla
70
3.6k
mthomps
38
2.3k
dotmariusz
94
5.5k
chrislema
173
14k
wjessup
339
16k
moore
125
21k
mza
80
4.1k
cherdarchuk
71
260k
morganepeng
93
14k
frogandcode
128
20k
3n
163
22k
Transcript
A practical intro to snapshot testing
About me Freek Van der Herten Partner & developer at
SPATIE @freekmurze https://murze.be
About me phpantwerp.be Dries Vints @driesvints Frederick Vanbrabant @TheEdonian
Since 2003 Websites, applications and webshops Team 4 developers, 1
manager Specialization Laravel development
OPEN SOURCE SOFTWARE
± 120 packages on Packagist Laravel, Framework agnostic PHP ±
4 000 000 downloads in total, growing ±500 000 a month We create a lot of it Open source software
http://github-awards.com/users?type=world&language=php Open source software
LET’S TALK SNAPSHOT TESTING
A file on disk, let’s call in snapshot Test succeeds
if output matches snapshot If not, test will fail What?
Old name: characterization testing Popularized by Facebook Jest Testing interfaces
Where does it come from?
https://github.com/spatie/phpunit-snapshot-assertions assertMatchesSnapshot assertMatchesJsonSnapshot assertMatchesXmlSnapshot How can we do it in
PHP?
DEMO
WRAPPING UP
Advantages Very easy to get started with Can be used
to validate complex output Easily update all the tests in one go
Disadvantages Brittle Hard to pinpoint exact point of failure Bugs
can be easily written in the snapshots
https://github.com/spatie/phpunit-snapshot-assertions https://sebastiandedeyne.com/posts/2017/a-package-for-snapshot- testing-in-phpunit https://murze.be/2017/04/practical-introduction-snapshot-testing/ https://www.sitepoint.com/snapshot-testing-viable-php/ https://facebook.github.io/jest/docs/snapshot-testing.html Interesting links
Thank you! https://speakerdeck.com/freekmurze/snapshot-testing-nomadphp https://spatie.be/opensource https://murze.be https://murze.be/newsletter/
QUESTIONS?