Skip to content

mauro-baptista/phpunit-slow-tests

Repository files navigation

Get a better overview of the slowest tests in your suite

Latest Version on Packagist Tests

Installation

You can install the package via composer:

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

Usage

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

  <extensions>
    <extension class="MauroBaptista\SlowTests\Extensions\ResultToCSV">
      <arguments>
        <string>tests/report/result.csv</string>
      </arguments>
    </extension>
    <extension class="MauroBaptista\SlowTests\Extensions\SlowestTests" />
  </extensions>

Configuration

ResultToCSV Extension

A CSV export of the time of all ran tests will be stored in this file.

<extensions>
    <extension class="MauroBaptista\SlowTests\Extensions\ResultToCSV">
        <arguments>
            <string>tests/report/result.csv</string>
        </arguments>
    </extension>
</extensions>

Arguments:

Argument Type Default Note
file string result.csv Path to the file (can be a relative path)

Output:

Console:

Result to CSV

File:

datetime,class,method,duration
"2022-11-08 02:06:23","Tests\Unit\ExampleTest",that_true_is_true,0.0055065
"2022-11-08 02:06:23","Tests\Feature\ExampleTest",that_true_is_true,0.186276667

SlowestTests

<extensions>
    <extension class="MauroBaptista\SlowTests\Extensions\SlowestTests">
        <arguments>
            <integer>10</integer>
            <array>
                <element key="success">
                    <double>0.1</double>
                </element>
                <element key="warning">
                    <double>1</double>
                </element>
            </array>
        </arguments>
    </extension>
</extensions>

Arguments:

Argument Type Default Note
show integer 10 Amount of tests that will be shown after the test ran
threshold array ['success' => 0.1, 'warning' => 1] Time to show tests as green, yellow, or red (in seconds)

Output:

Console:

Slowest Tests

Testing

composer test

Credits

License

The MIT License (MIT). Please see License File for more information.

About

Get a better overview of the slowests tests in your suite

Resources

License

Stars

Watchers

Forks

Sponsor this project

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages