keystone/phpunit-broom-wagon 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

keystone/phpunit-broom-wagon

Composer 安装命令:

composer require keystone/phpunit-broom-wagon

包简介

Find slow tests within your PHPUnit test suite.

README 文档

README

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.

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.

Broom wagon

Installation

Install via Composer

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

Usage

Enable the listener by adding it to your phpunit.xml configuration file.

<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.

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.

<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):

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.

Group thresholds:

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.

Report length (default 10):

The third argument is the number of slow tests to display in the PHPUnit output.

Annotations

The @slowThreshold annotation can be added to test classes or test methods to override any suite or group thresholds.

/**
 * @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.

统计信息

  • 总下载量: 370
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 5
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-01-20

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固