2017 © Pedro Peláez
 

library phpunit-broom-wagon

Find slow tests within your PHPUnit test suite.

image

keystone/phpunit-broom-wagon

Find slow tests within your PHPUnit test suite.

  • Sunday, February 5, 2017
  • by tompedals
  • Repository
  • 0 Watchers
  • 1 Stars
  • 109 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

PHPUnit Broom Wagon

A PHPUnit test listener that reports on slow-running tests. Forked from johnkary/phpunit-speedtrap to allow more control over slow thresholds and support for PHPUnit 5., (*1)

Broom Wagon?

The broom wagon is the name given to the vehicle that follows a cycling road race "sweeping" up stragglers who are unable to make it to the finish of the race within the time permitted. As a cyclist it makes sense to me., (*2)

Broom wagon, (*3)

Installation

Install via Composer, (*4)

composer require --dev keystone/phpunit-broom-wagon

Usage

Enable the listener by adding it to your phpunit.xml configuration file., (*5)

<phpunit bootstrap="vendor/autoload.php">
    <listeners>
        <listener class="Keystone\PHPUnit\BroomWagon\TestListener" />
    </listeners>
</phpunit>

Now run your test suite as normal. If tests take longer than the slow threshold (500ms by default), then they will be reported on in the console after the suite completes., (*6)

PHPUnit 5.7.5 by Sebastian Bergmann and contributors.

..........                                                        10 / 10 (100%)

Recorded 6 slow tests:
 1. 516ms to run ExampleTest:testSomething (expected <500ms)
 2. 1004ms to run ExampleTest:testTest with data set "e" (expected <800ms)
 3. 1000ms to run ExampleTest:testTest with data set "d" (expected <800ms)
 4. 1002ms to run ExampleTest:testTest with data set "c" (expected <800ms)
 5. 1004ms to run ExampleTest:testTest with data set "b" (expected <800ms)
 6. 1005ms to run ExampleTest:testTest with data set "a" (expected <800ms)

Time: 10.24 seconds, Memory: 4.00MB

Configuration

Within the configuration a number of arguments can optionally be passed to the test listener., (*7)

<phpunit bootstrap="vendor/autoload.php">
    <listeners>
        <listener class="Keystone\PHPUnit\BroomWagon\TestListener">
            <arguments>
                <!-- Suite threshold -->
                <integer>100</integer>
                <!-- Group thresholds -->
                <array>
                    <element key="database">
                        <integer>1000</integer>
                    </element>
                    <element key="browser">
                        <integer>5000</integer>
                    </element>
                </array>
                <!-- Report length -->
                <integer>10</integer>
            </arguments>
        </listener>
    </listeners>
</phpunit>

Suite threshold (default 500ms):, (*8)

The first argument is the overall suite threshold. This is the number of milliseconds a test can take to execute before it is deemed as slow., (*9)

Group thresholds:, (*10)

The second argument is an array of group thresholds. Each test @group annotation can have a different threshold. A use case for this is to group all tests that hit the database and be a little more relaxed with the slow threshold., (*11)

Report length (default 10):, (*12)

The third argument is the number of slow tests to display in the PHPUnit output., (*13)

Annotations

The @slowThreshold annotation can be added to test classes or test methods to override any suite or group thresholds., (*14)

/**
 * @slowThreshold 2000
 */
class SomeTestCase extends \PHPUnit_Framework_TestCase
{
    /**
     * @slowThreshold 5000
     */
    public function testLongRunningProcess()
    {
    }
}

Credits

License

Released under the MIT Licence. See the bundled LICENSE file for details., (*15)

The Versions

05/02 2017

dev-master

9999999-dev

Find slow tests within your PHPUnit test suite.

  Sources   Download

MIT

The Requires

 

phpunit profile slow

05/02 2017

1.0.0

1.0.0.0

Find slow tests within your PHPUnit test suite.

  Sources   Download

MIT

The Requires

 

phpunit profile slow