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
320
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
Uncharted packages (Laravel Live Denmark)
freekmurze
0
180
I shall define this only once
freekmurze
0
370
An Introduction to Snapshot testing
freekmurze
0
460
Event Sourcing In Laravel
freekmurze
0
230
Building a realtime dashboard with Laravel Livewire (PHPKonf)
freekmurze
0
760
A tour behind the scenes of Oh Dear (PHP Benelux)
freekmurze
2
820
A practical look at multitenancy in Laravel
freekmurze
1
330
A practical look at multitenancy in Laravel (Laracon US)
freekmurze
0
700
Highlights Flare codebase (Laracon online)
freekmurze
0
460
Other Decks in Programming
See All in Programming
sappoRo.R #12 初心者セッション
kosugitti
0
250
SwiftUI Viewの責務分離
elmetal
PRO
1
230
iOSエンジニアから始める visionOS アプリ開発
nao_randd
3
130
Bedrock Agentsレスポンス解析によるAgentのOps
licux
3
840
ファインディLT_ポケモン対戦の定量的分析
fufufukakaka
0
710
Flutter × Firebase Genkit で加速する生成 AI アプリ開発
coborinai
0
160
GoとPHPのインターフェイスの違い
shimabox
2
190
Amazon ECS とマイクロサービスから考えるシステム構成
hiyanger
2
550
仕様変更に耐えるための"今の"DRY原則を考える / Rethinking the "Don't repeat yourself" for resilience to specification changes
mkmk884
0
140
データベースのオペレーターであるCloudNativePGがStatefulSetを使わない理由に迫る
nnaka2992
0
150
法律の脱レガシーに学ぶフロントエンド刷新
oguemon
5
740
第3回 Snowflake 中部ユーザ会- dbt × Snowflake ハンズオン
hoto17296
4
370
Featured
See All Featured
Documentation Writing (for coders)
carmenintech
67
4.6k
Facilitating Awesome Meetings
lara
52
6.2k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
3.7k
Why Our Code Smells
bkeepers
PRO
336
57k
Site-Speed That Sticks
csswizardry
4
380
Building Your Own Lightsaber
phodgson
104
6.2k
The Cult of Friendly URLs
andyhume
78
6.2k
Typedesign – Prime Four
hannesfritz
40
2.5k
The Language of Interfaces
destraynor
156
24k
Statistics for Hackers
jakevdp
797
220k
Building Better People: How to give real-time feedback that sticks.
wjessup
367
19k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
507
140k
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?