keisuke-matsufuji / phpunit-blocker
该包的最新版本(1.0.3)没有提供许可证信息。
阻止 phpunit10 以上版本的过滤器选项
1.0.3
2024-05-23 01:56 UTC
Requires
- phpunit/phpunit: >=10.0.0
README
PHPUnitBlocker 是 PHPUnit 框架的 StartedSubscriber 的自定义实现。它主要阻止 PHPUnit 的过滤器选项,以防止在 CI 中出现配置错误。
注意,此库与 PHPUni10 或更高版本兼容。如果您使用的是 PHPUnit 9 或更早版本,请参考以下链接。 https://github.com/genkiroid/phpunit-filter-blocker
安装
$ composer require keisuke-matsufuji/phpunit-blocker
设置
要将 PHPUnitFilterBlocker 作为测试监听器附加,请将以下元素添加到 phpunit.xml 中。(父元素是 <phpunit>
。)
<?xml version="1.0"?> <phpunit> <extensions> <bootstrap class="PHPUnitBlocker\Extension"> <parameter name="blockGroup" value="On"/> <parameter name="blockExcludeGroup" value="On"/> </bootstrap> </extensions> </phpunit>
如果您还想阻止 --group
和 --exclude-group
选项,请将上面的设置值从 Off
改为 On
。
关于阻止
阻止测试用例指定。(已修复)
$ vendor/bin/phpunit tests/exampleTest.php
PHPUnit 10.5.10 by Sebastian Bergmann and contributors.
Test case specification has been disabled by phpunit-blocker. Stopped phpunit.
阻止 --filter
选项。(已修复)
$ vendor/bin/phpunit tests/ --filter="Hello"
PHPUnit 10.5.10 by Sebastian Bergmann and contributors.
--filter option has been disabled by phpunit-blocker. Stopped phpunit.
阻止 --group
选项。(选项)
$ vendor/bin/phpunit tests/ --group=hello
PHPUnit 10.5.10 by Sebastian Bergmann and contributors.
--group option has been disabled by phpunit-blocker. Stopped phpunit.
阻止 --exclude-group
选项。(选项)
$ vendor/bin/phpunit tests/ --exclude-group=hello
PHPUnit 10.5.10 by Sebastian Bergmann and contributors.
--exclude-group option has been disabled by phpunit-blocker. Stopped phpunit.
无阻止示例。
$ vendor/bin/phpunit tests/
PHPUnit 10.5.10 by Sebastian Bergmann and contributors.
.. 2 / 2 (100%)
Time: 83 ms, Memory: 6.00 MB
OK (2 tests, 2 assertions)