MauroBaptista.com

Package to see PHPUnit tests running time

PHPUnit Test

As I prefer to go for Integration test, then Unit tests, sometime I was falling in a pit where some tests were taking too much time, which makes it hard to run the whole suite of tests, and also it takes more time to run the CI/CD.

With that in mind, I developed a package that you simple show you the slowest tests in your suite, but also will be able to store all the test times in a CSV, so you can have a better overview of your test suite.

Installing:

1composer require maurobaptista/phpunit-slow-tests --dev

Using:

In your phpunit.xml file, add the extensions as below.

1<extensions>
2 <extension class="MauroBaptista\SlowTests\Extensions\ResultToCSV">
3 <arguments>
4 <string>tests/report/result.csv</string>
5 </arguments>
6 </extension>
7 <extension class="MauroBaptista\SlowTests\Extensions\SlowestTests" />
8</extensions>

Sample output:

Package output

Package:

For more information on the arguments for each extension and more details about the package, please visit its page in https://github.com/maurobaptista/phpunit-slow-tests.