Skip to content
Switch branches/tags

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

PHPUnit Extensions

Latest Version on Packagist Build Status Quality Score Total Downloads Buy us a tree

This package provides you a few useful extensions for your testsuite in an effort to improve your code.


You can install the package via composer:

composer require lloople/phpunit-extensions --dev

Add the Extension to your phpunit.xml file:

    <extension class="Lloople\PHPUnitExtensions\Runners\SlowestTests\Console" />



Output the slowest tests on the console.

<extension class="Lloople\PHPUnitExtensions\Runners\SlowestTests\Console"/>
Showing the top 5 slowest tests:
  543 ms: Tests\Feature\ProfileTest::can_upload_new_profile_image
   26 ms: Tests\Feature\ProfileTest::can_visit_profile_page
   25 ms: Tests\Feature\ProfileTest::throws_validation_error_if_password_not_match

Default options are:

  • rows: 5 (Report 5 tests max)
  • min: 200 (Report tests slower than 200ms)


Write the tests in a CSV file ready for import.

<extension class="Lloople\PHPUnitExtensions\Runners\SlowestTests\Csv"/>

Default options are:

  • file: phpunit_results.csv
  • rows: null (all the tests)
  • min: 200


Write the tests in a JSON file ready for import.

<extension class="Lloople\PHPUnitExtensions\Runners\SlowestTests\Json"/>

Default options are:

  • file: phpunit_results.json
  • rows: null (all the tests)
  • min: 200


Store the test name and the time into a MySQL database. It will override existing records

<extension class="Lloople\PHPUnitExtensions\Runners\SlowestTests\MySQL"/>

Default credentials are (as array):

  • database: phpunit_results
  • table: default
  • username: root
  • password: ``
  • host:
  • rows: null (all the tests)
  • min: 200


Store the test name and the time into a SQLite database. It will override existing records

<extension class="Lloople\PHPUnitExtensions\Runners\SlowestTests\SQLite"/>

Default credentials are (as array):

  • database: phpunit_results.db
  • table: default
  • rows: null (all the tests)
  • min: 200


To override the default configuration per extension, you need to use <arguments>in your phpunit.xml file

<extension class="Lloople\PHPUnitExtensions\Runners\SlowestTests\Json">
    <integer>10</integer> <!-- Max number of tests to report. -->
    <integer>400</integer> <!-- Min miliseconds to report a test. -->

In the case of the MySQL and SQLite, which needs a database connection, configuration goes as array

<extension class="Lloople\PHPUnitExtensions\Runners\SlowestTests\MySQL">
      <element key="database">
      <element key="table">
      <element key="username">
      <element key="password">
      <element key="host">

You don't need to override those credentials that already fit to your usecase, since the class will merge your configuration with the default one


Please see CHANGELOG for more information what has changed recently.


Please see CONTRIBUTING for details.


If you discover any security related issues, please email instead of using the issue tracker.



You're free to use this package, but if it is really useful for you I would highly appreciate you buying the world a tree.

It’s now common knowledge that one of the best tools to tackle the climate crisis and keep our temperatures from rising above 1.5C is to plant trees. If you contribute to Treeware's forest you’ll be creating employment for local families and restoring wildlife habitats.

You can buy trees here

Read more about Treeware at