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
290
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
140
I shall define this only once
freekmurze
0
340
An Introduction to Snapshot testing
freekmurze
0
410
Event Sourcing In Laravel
freekmurze
0
210
Building a realtime dashboard with Laravel Livewire (PHPKonf)
freekmurze
0
710
A tour behind the scenes of Oh Dear (PHP Benelux)
freekmurze
2
750
A practical look at multitenancy in Laravel
freekmurze
1
290
A practical look at multitenancy in Laravel (Laracon US)
freekmurze
0
660
Highlights Flare codebase (Laracon online)
freekmurze
0
400
Other Decks in Programming
See All in Programming
デザインシステムとコンポーネント指向によるフロントエンド開発プロセスの革新 / Innovation in Frontend Development Processes through Design Systems and Component-Oriented Architecture
nrslib
8
5.3k
マイグレーションコード自作して File-Based Routing に自動移行!! ~250 ページの歴史的経緯を添えて~
cut0
1
260
RAGの回答精度評価用のQAデータセットを生成AIに作らせた話
kurahara
0
240
dRuby 入門者によるあなたの身近にあるdRuby 入門
makicamel
4
350
サーバーレスで負荷試験!Step Functions + Lambdaを使ったk6の分散実行
shuntakahashi
6
1.5k
The Sequel to a Dream of Ruby Parser's Grammar
ydah
1
210
Our Websites Need a Lifestyle Change, Not a Diet
ryantownsend
0
120
いつか使える ObjectSpace / Maybe useful ObjectSpace
euglena1215
2
130
[DroidKaigi 2024] Android ViewからJetpack Composeへ 〜Jetpack Compose移行のすゝめ〜 / From Android View to Jetpack Compose: A Guide to Migration
syarihu
1
250
null or undefined
susisu
22
6.2k
今インフラ技術をイチから学び直すなら
yuhta28
1
120
Desafios e Lições Aprendidas na Migração de Monólitos para Microsserviços em Java
jessilyneh
2
140
Featured
See All Featured
Reflections from 52 weeks, 52 projects
jeffersonlam
346
20k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
25
1.3k
Writing Fast Ruby
sferik
623
60k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
24
3.9k
The MySQL Ecosystem @ GitHub 2015
samlambert
250
12k
Bootstrapping a Software Product
garrettdimon
PRO
304
110k
What's in a price? How to price your products and services
michaelherold
242
11k
We Have a Design System, Now What?
morganepeng
48
7.1k
How to train your dragon (web standard)
notwaldorf
85
5.6k
The Invisible Side of Design
smashingmag
295
50k
jQuery: Nuts, Bolts and Bling
dougneiner
61
7.4k
Web development in the modern age
philhawksworth
204
10k
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?