Set a max timeout for your PHPUnit tests
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 π