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
snapshot testing (phplimburg)
Search
Freek Van der Herten
September 07, 2017
Programming
1
260
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
330
An Introduction to Snapshot testing
freekmurze
0
360
Event Sourcing In Laravel
freekmurze
0
200
Building a realtime dashboard with Laravel Livewire (PHPKonf)
freekmurze
0
670
A tour behind the scenes of Oh Dear (PHP Benelux)
freekmurze
2
690
A practical look at multitenancy in Laravel
freekmurze
1
280
A practical look at multitenancy in Laravel (Laracon US)
freekmurze
0
610
Highlights Flare codebase (Laracon online)
freekmurze
0
340
Introducing Mailcoach
freekmurze
1
520
Other Decks in Programming
See All in Programming
try!Swift Tokyo 2024 参加報告 LT
akidon0000
1
220
MetricKitで予期せぬ終了を検知する話 / Detect unexpected termination with MetricKit
nekowen
1
190
Amazon SQSコンシューマー疎結合への旅 - 出張! #DevelopersIO IT技術ブログの中の人が語る勉強会 #3
quiver
0
270
Prepare for Jakarta EE 11 - Performance and Developer Productivity
ivargrimstad
0
810
Tailwind CSSを本気でカスタマイズする方法
fsubal
13
5.3k
PHP8.3の機能を振り返る / Review of PHP 8.3 features
seike460
PRO
1
110
Ruby GitHub Packages
bkuhlmann
0
630
新宿ダンジョンを可視化してみた
satoshi7190
2
260
PostmanでAPIの動作確認が楽になった話
h455h1
0
170
スキーマ駆動開発による品質とスピードの両立 - 私達は何故、スキーマを書くのか
kentaroutakeda
0
170
効率化に挑戦してみたらモバイル開発が少し快適になった話
ryunakayama
0
130
AWS Application Composerで始める、 サーバーレスなデータ基盤構築 / 20240406-jawsug-hokuriku-shinkansen
kasacchiful
1
260
Featured
See All Featured
Web Components: a chance to create the future
zenorocha
305
41k
Rebuilding a faster, lazier Slack
samanthasiow
73
8.2k
Creatively Recalculating Your Daily Design Routine
revolveconf
210
11k
Teambox: Starting and Learning
jrom
128
8.4k
Docker and Python
trallard
34
2.7k
The Mythical Team-Month
searls
216
42k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
244
20k
Designing with Data
zakiwarfel
96
4.8k
Visualization
eitanlees
136
14k
The World Runs on Bad Software
bkeepers
PRO
61
6.7k
Building Effective Engineering Teams - LeadDev
addyosmani
28
1.8k
The Pragmatic Product Professional
lauravandoore
25
5.8k
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?