Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Pest: bring back the joy of testing in PHP
Search
Claudio La Barbera
June 01, 2023
Programming
100
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Pest: bring back the joy of testing in PHP
A brief introduction to Pest: the new PHP testing framework with a focus on simplicity
Claudio La Barbera
June 01, 2023
More Decks by Claudio La Barbera
See All by Claudio La Barbera
Wordpress + Laravel Mix
thebatclaudio
0
250
Other Decks in Programming
See All in Programming
dotNET_vulnclicker_intro.pdf
deka_morita
0
140
ハーネス設計入門 〜 基礎知識の整理から実務へのステップアップ 〜
kinopeee
28
32k
ActionController meets Protocol Buffers
sorah
0
530
AIに “答え“を書かせるのを やめてみた
___akari11
0
120
自サークルのIdPからログアウトできるようになるまで
taiseiue
1
140
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
190
[2026-09-26]空論ジェネリックプロセス~テスト資産とAIで紡ぐ、再現可能なパフォーマンスチューニングの話~
tosite
0
270
作れる、でも消せるか?──安全に「枯らして消す」機能削除術 / Drain, Then Delete
chobishiba
2
700
phperだってパンチカードでコーディングしたい
o0h
PRO
0
340
Simple Storage Service(S3) is not simple
iwatsukayura
0
290
FactoryBotをやめればRSpecは速くなるのか?
yuta_onishi_97
0
540
コードレビューのボトルネックを"する側"と"される側"の両面から解消する
yub0n
2
1.6k
Featured
See All Featured
The agentic SEO stack - context over prompts
schlessera
0
970
GitHub's CSS Performance
jonrohan
1033
470k
Evolving SEO for Evolving Search Engines
ryanjones
0
330
Accessibility Awareness
sabderemane
1
250
jQuery: Nuts, Bolts and Bling
dougneiner
66
8.6k
The Spectacular Lies of Maps
axbom
PRO
1
1.1k
svc-hook: hooking system calls on ARM64 by binary rewriting
retrage
2
630
Highjacked: Video Game Concept Design
rkendrick25
PRO
1
480
How to Grow Your eCommerce with AI & Automation
katarinadahlin
PRO
2
330
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
133
20k
Conquering PDFs: document understanding beyond plain text
inesmontani
PRO
4
3.2k
The untapped power of vector embeddings
frankvandijk
2
1.9k
Transcript
Bring back the joy of testing in PHP Tech and
Beer #2, 31st May 2023 Sponsored by
{ “name”: “Claudio La Barbera”, “role”: “Full Stack Developer”, “company”:
“Angelini Consumer”, “linkedin”: “https://www.linkedin.com/in/claudio-la-barbera”, “github”: “https://github.com/thebatclaudio” }
What is PEST? Pest is a testing framework with a
focus on simplicity, meticulously designed to bring back the joy of testing in PHP. pestphp.com
PEST is built on top of PHPUnit! Your current PHPUnit
test suite will work flawlessly with Pest. No need to change a thing.
Installation composer require pestphp/pest --dev --with-all-dependencies First step: require Pest
as a “dev” dependency on your project: Second step: initialize Pest on your project: ./vendor/bin/pest --init Finally: you can run your tests: ./vendor/bin/pest php artisan test If you are using Laravel you can also run:
Installation Here is an example of the output in a
new Laravel project:
Installation Here is an example of the folder structure in
a new Laravel project:
From PHPUnit to Pest: PHPUnit
From PHPUnit to Pest: Pest
Writing tests
test() function
test() function
it() function
skip() function
skip() function
skip() function
Expectation API
Assert multiple conditions
Assert multiple conditions with expect() function
Datasets
Using datasets
Using datasets
Using datasets
Using datasets
Bound Datasets
Bound Datasets
Sharing Datasets
Sharing Datasets
Sharing Datasets
Sharing Datasets
Database
Using database
Using database
Using database
Using database
Demo We will integrate Pest on a simple Laravel project
that expose some APIs. https://github.com/thebatclaudio/bat-tasks
Testing API: example POST /api/tasks Payload: ONLY ADMIN CAN CREATE
TASKS!
Testing API: example
Testing API: example
Testing API: example
Testing API: example
Custom helpers
Custom helpers
Custom helpers
Custom helpers
Check coverage (--coverage option) ./vendor/bin/pest --coverage
Check coverage (--min option) ./vendor/bin/pest --coverage --min=50
Parallel Testing ./vendor/bin/pest --parallel
Parallel Testing ./vendor/bin/pest --parallel --processes=20
In conclusion, Pest: • is easy to use • is
easy to learn • is easy to read • make easy to migrate from PHPUnit • has a growing community and frequent updates
Some links: • https://pestphp.com/ • https://github.com/pestphp/pest • https://www.youtube.com/watch?v=MqiGA34ZrQU • https://laravel.com/docs/10.x/readme
Thank you!