genkiroid/phpunit-filter-blocker

此包的最新版本(2.0.0)没有提供许可证信息。

阻止 phpunit 过滤器选项

2.0.0 2020-02-18 10:17 UTC

This package is auto-updated.

Last update: 2024-09-28 04:46:51 UTC


README

PHPUnitFilterBlocker 是 PHPUnit 框架 TestListener 的自定义实现。它主要阻止 PHPUnit 的过滤器选项,以防止在 CI 中出现配置错误。

CI

安装

$ composer require genkiroid/phpunit-filter-blocker

设置

要将 PHPUnitFilterBlocker 作为测试监听器附加,请将以下元素添加到 phpunit.xml 中。(父元素是 <phpunit>。)

<listeners>
    <listener class="PHPUnitFilterBlocker\Listener">
        <arguments>
            <array>
                <element key="blockGroup">
                    <boolean>false</boolean>
                </element>
                <element key="blockExcludeGroup">
                    <boolean>false</boolean>
                </element>
            </array>
        </arguments>
    </listener>
</listeners>

如果您还想阻止 --group--exclude-group 选项,将上述设置中的 false 更改为 true

关于阻止

阻止测试用例指定。(已修复)

$ vendor/bin/phpunit tests/exampleTest.php
PHPUnit 9.0.1 by Sebastian Bergmann and contributors.

Test case specification has been disabled by phpunit-filter-blocker. Stopped phpunit.

阻止 --filter 选项。(已修复)

$ vendor/bin/phpunit tests/ --filter="Hello"
PHPUnit 9.0.1 by Sebastian Bergmann and contributors.

--filter option has been disabled by phpunit-filter-blocker. Stopped phpunit.

阻止 --group 选项。(可选)

$ vendor/bin/phpunit tests/ --group=hello
PHPUnit 9.0.1 by Sebastian Bergmann and contributors.

--group option has been disabled by phpunit-filter-blocker. Stopped phpunit.

阻止 --exclude-group 选项。(可选)

$ vendor/bin/phpunit tests/ --exclude-group=hello
PHPUnit 9.0.1 by Sebastian Bergmann and contributors.

--exclude-group option has been disabled by phpunit-filter-blocker. Stopped phpunit.

无阻止示例。

$ vendor/bin/phpunit tests/
PHPUnit 9.0.1 by Sebastian Bergmann and contributors.

..                                                                  2 / 2 (100%)

Time: 83 ms, Memory: 6.00 MB

OK (2 tests, 2 assertions)