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 (phplimburg)
Freek Van der Herten
September 07, 2017
Programming
1
180
snapshot testing (phplimburg)
Freek Van der Herten
September 07, 2017
Tweet
Share
More Decks by Freek Van der Herten
See All by Freek Van der Herten
I shall define this only once
freekmurze
0
240
An Introduction to Snapshot testing
freekmurze
0
250
Event Sourcing In Laravel
freekmurze
0
160
Building a realtime dashboard with Laravel Livewire (PHPKonf)
freekmurze
0
530
A tour behind the scenes of Oh Dear (PHP Benelux)
freekmurze
2
540
A practical look at multitenancy in Laravel
freekmurze
1
250
A practical look at multitenancy in Laravel (Laracon US)
freekmurze
0
500
Highlights Flare codebase (Laracon online)
freekmurze
0
220
Introducing Mailcoach
freekmurze
1
420
Other Decks in Programming
See All in Programming
Amebaブログの会員画面システム刷新の道程
ryotasugawara
1
230
爆速の日経電子版開発の今
shinyaigeek
2
610
PHPアプリケーションにおけるアーキテクチャメトリクスについて / Architecture Metrics in PHP Applications
isanasan
1
250
Gradle build: The time is now
nonews
1
470
NGK2023S - OCaml最高! スマホ開発にも使えちゃう?!
haochenxie
0
120
AWSにおける標的型Bot対策
hacomono
0
420
Functional Data Engineering - A Blueprint for adopting functional principles in data pipeline
vananth22
0
180
LIFFで動く割り勘アプリTATEKAをリリースしてみた話
inoue2002
0
250
Excelの助けを借りて楽にシナリオを作ろう
rpa_niiyama
0
300
(新米)エンジニアリングマネージャーのしごと #RSGT2023
murabayashi
9
5.8k
ポケモンで学ぶiOS 16弾丸ツアー 🚅
giginet
PRO
1
610
Hasura の Relationship と権限管理
karszawa
0
170
Featured
See All Featured
Understanding Cognitive Biases in Performance Measurement
bluesmoon
2
400
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
24
4.5k
The Brand Is Dead. Long Live the Brand.
mthomps
48
2.9k
It's Worth the Effort
3n
177
26k
Fontdeck: Realign not Redesign
paulrobertlloyd
74
4.3k
Designing on Purpose - Digital PM Summit 2013
jponch
108
5.9k
Pencils Down: Stop Designing & Start Developing
hursman
114
10k
Scaling GitHub
holman
453
140k
JazzCon 2018 Closing Keynote - Leadership for the Reluctant Leader
reverentgeek
175
9.1k
Writing Fast Ruby
sferik
613
58k
Put a Button on it: Removing Barriers to Going Fast.
kastner
56
2.5k
5 minutes of I Can Smell Your CMS
philhawksworth
198
18k
Transcript
A practical intro to snapshot testing and PHPUnit-watcher
About me Freek Van der Herten Partner & developer at
SPATIE Blogging at https://murze.be https://murze.be/newsletter
OPEN SOURCE SOFTWARE
https://spatie.be/en/opensource/laravel
Open source software ± 160 public repositories on GitHub August
2016: ± 800 000 downloads August 2017: ± 5 000 000 downloads ± 500 000 downloads a month
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?
Another 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 https://github.com/spatie/phpunit-watcher Interesting links
Thank you! https://speakerdeck.com/freekmurze/snapshot-testing-phplimburg https://spatie.be/opensource https://murze.be https://murze.be/newsletter/
QUESTIONS?