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
Pest: bring back the joy of testing in PHP
Search
Claudio La Barbera
June 01, 2023
Programming
0
100
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
Tweet
Share
More Decks by Claudio La Barbera
See All by Claudio La Barbera
Wordpress + Laravel Mix
thebatclaudio
0
230
Other Decks in Programming
See All in Programming
これならできる!個人開発のすゝめ
tinykitten
PRO
0
150
PostgreSQLで手軽にDuckDBを使う!DuckDB&pg_duckdb入門/osc25hi-duckdb
takahashiikki
0
250
HTTPプロトコル正しく理解していますか? 〜かわいい猫と共に学ぼう。ฅ^•ω•^ฅ ニャ〜
hekuchan
2
640
例外処理とどう使い分ける?Result型を使ったエラー設計 #burikaigi
kajitack
16
5.4k
CSC307 Lecture 03
javiergs
PRO
1
480
AtCoder Conference 2025「LLM時代のAHC」
imjk
2
660
re:Invent 2025 のイケてるサービスを紹介する
maroon1st
0
170
インターン生でもAuth0で認証基盤刷新が出来るのか
taku271
0
160
TestingOsaka6_Ozono
o3
0
270
ThorVG Viewer In VS Code
nors
0
670
KIKI_MBSD Cybersecurity Challenges 2025
ikema
0
140
[AtCoder Conference 2025] LLMを使った業務AHCの上⼿な解き⽅
terryu16
6
1k
Featured
See All Featured
Product Roadmaps are Hard
iamctodd
PRO
55
12k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
54k
So, you think you're a good person
axbom
PRO
1
1.9k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
Intergalactic Javascript Robots from Outer Space
tanoku
273
27k
Mozcon NYC 2025: Stop Losing SEO Traffic
samtorres
0
120
4 Signs Your Business is Dying
shpigford
187
22k
A better future with KSS
kneath
240
18k
How Software Deployment tools have changed in the past 20 years
geshan
0
31k
Leading Effective Engineering Teams in the AI Era
addyosmani
9
1.5k
AI in Enterprises - Java and Open Source to the Rescue
ivargrimstad
0
1.1k
Agile Actions for Facilitating Distributed Teams - ADO2019
mkilby
0
100
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!