Member-only story

Set a max timeout for your PHPUnit tests

Smaine Milianni
1 min readAug 18, 2022

--

πŸ“š You can set your tests as risky if they reach a timeout
by adding an annotation on top of the method. (@large, @medium or @small)

Example:

πŸ’‘ But what about having the possibility to set a global timeout and allow to customize it for each test?

🌸 1- Create the timeout configuration

I’ll create a class with a static public property as it’s straightforward for configuration.

βœ… 2- Create the Assertion

PHPUnit allows us to hook the end of each test and recover the execution time, we will add our assertion in this hook πŸ˜„

--

--

Smaine Milianni
Smaine Milianni

Written by Smaine Milianni

Engineering Manager- Technical Lead - certified Symfony 7,6,5,4 and certified AWS Solution Architect - Remote Worker

No responses yet