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
170
I shall define this only once
freekmurze
0
370
An Introduction to Snapshot testing
freekmurze
0
450
Event Sourcing In Laravel
freekmurze
0
220
Building a realtime dashboard with Laravel Livewire (PHPKonf)
freekmurze
0
750
A tour behind the scenes of Oh Dear (PHP Benelux)
freekmurze
2
810
A practical look at multitenancy in Laravel
freekmurze
1
320
A practical look at multitenancy in Laravel (Laracon US)
freekmurze
0
690
Highlights Flare codebase (Laracon online)
freekmurze
0
450
Other Decks in Programming
See All in Programming
Rubyでつくるパケットキャプチャツール
ydah
0
170
テストコード書いてみませんか?
onopon
2
340
functionalなアプローチで動的要素を排除する
ryopeko
1
200
サーバーゆる勉強会 DBMS の仕組み編
kj455
1
300
AHC041解説
terryu16
0
380
PSR-15 はあなたのための ものではない? - phpcon2024
myamagishi
0
400
[JAWS-UG横浜 #80] うわっ…今年のServerless アップデート、少なすぎ…?
maroon1st
0
100
毎日13時間もかかるバッチ処理をたった3日で60%短縮するためにやったこと
sho_ssk_
1
550
Внедряем бюджетирование, или Как сделать хорошо?
lamodatech
0
940
GitHub CopilotでTypeScriptの コード生成するワザップ
starfish719
26
6k
ESLintプラグインを使用してCDKのセオリーを適用する
yamanashi_ren01
2
240
ASP.NET Core の OpenAPIサポート
h455h1
0
110
Featured
See All Featured
Understanding Cognitive Biases in Performance Measurement
bluesmoon
27
1.5k
Automating Front-end Workflow
addyosmani
1366
200k
Why You Should Never Use an ORM
jnunemaker
PRO
54
9.1k
Thoughts on Productivity
jonyablonski
68
4.4k
Mobile First: as difficult as doing things right
swwweet
222
9k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
38
1.9k
The Invisible Side of Design
smashingmag
299
50k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
47
5.1k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
How to Think Like a Performance Engineer
csswizardry
22
1.3k
What's in a price? How to price your products and services
michaelherold
244
12k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
10
860
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?