method
有没有办法更改PHPUnit 用于查找测试的名称?我想将默认test
前缀更改为使用 BDD 样式并开始it
。
我的搜索只找到了使用 phpunit.xml 配置更改文件名的方法,
<directory prefix="test-" suffix=".php">./tests/</directory>
Run Code Online (Sandbox Code Playgroud)
谢谢。
我做了一些挖掘,发现Framework\TestSuite.php
:
public static function isTestMethod(ReflectionMethod $method)
{
if (strpos($method->name, 'test') === 0) {
return TRUE;
}
// @scenario on TestCase::testMethod()
// @test on TestCase::testMethod()
return strpos($method->getDocComment(), '@test') !== FALSE ||
strpos($method->getDocComment(), '@scenario') !== FALSE;
}
Run Code Online (Sandbox Code Playgroud)
因此,名称要么以 开头,要么带有或"test"
注释。我已经确认注释有效。@test
@scenario
正如您所看到的,没有配置传递到此函数中,因此我认为您无法配置自定义前缀。