php - PHPUnit 7.5.6 上的 Disallow-todo-tests
问题描述
我正在尝试使用该选项phpunit --disallow-todo-tests
来忽略一些需要编写的测试。
--disallow-todo-tests
不执行在其文档块中具有 @todo 注释的测试。
我尝试了很多方法。这里有一些例子:
/**
* @test
* @todo: implement this
*/
public function my_random_test(): void
{
$this->assertTrue(false);
}
/**
* @todo: implement this
*/
public function test_my_another_random_test(): void
{
$this->assertTrue(false);
}
public function test_this_one_is_also_random(): void
{
/**
* @todo: implement this
*/
$this->assertTrue(false);
}
/**
* @test
* @todo implement this
*/
public function another_test(): void
{
$this->assertTrue(false);
}
也写了没有:
,@
或者像那样@todo-annotated
......没有任何效果。我总是遇到失败。
我有一个phpunit.xml文件
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false">
<testsuites>
<testsuite name="Unit">
<directory suffix="Test.php">./tests/Unit</directory>
</testsuite>
<testsuite name="Feature">
<directory suffix="Test.php">./tests/Feature</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./app</directory>
</whitelist>
</filter>
<php>
<env name="APP_ENV" value="testing"/>
<env name="BCRYPT_ROUNDS" value="4"/>
<env name="CACHE_DRIVER" value="array"/>
<env name="MAIL_DRIVER" value="array"/>
<env name="QUEUE_CONNECTION" value="sync"/>
<env name="SESSION_DRIVER" value="array"/>
</php>
</phpunit>
解决方案
@todo
后面不应有冒号。这就是 phpunit 找不到您的待办事项注释的原因。