Laravel 未配置白名单,不会生成代码覆盖率错误
我试图使用PhpStorm中的功能来覆盖代码,但它显示了以下错误: 没有配置白名单,不会生成代码覆盖率 我在本地Mac计算机上运行PHP7.2 编辑:我已经为白名单和登录添加了phpunit设置 这就是我的phpunit.xml文件的样子:Laravel 未配置白名单,不会生成代码覆盖率错误,laravel,phpunit,phpstorm,code-coverage,Laravel,Phpunit,Phpstorm,Code Coverage,我试图使用PhpStorm中的功能来覆盖代码,但它显示了以下错误: 没有配置白名单,不会生成代码覆盖率 我在本地Mac计算机上运行PHP7.2 编辑:我已经为白名单和登录添加了phpunit设置 这就是我的phpunit.xml文件的样子: <?xml version="1.0" encoding="UTF-8"?> <phpunit printerClass="Codedungeon\PHPUnitPrettyResultPrinter\Printer" b
<?xml version="1.0" encoding="UTF-8"?>
<phpunit printerClass="Codedungeon\PHPUnitPrettyResultPrinter\Printer"
backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false">
<testsuites>
<testsuite name="Feature">
<directory suffix="Test.php">./tests/Feature</directory>
</testsuite>
<testsuite name="Unit">
<directory suffix="Test.php">./tests/Unit</directory>
</testsuite>
</testsuites>
<filter>
<whitelist addUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./app</directory>
</whitelist>
</filter>
<logging>
<log type="coverage-html" target="./report" charset="UTF-8"
yui="true" highlight="true"
lowUpperBound="50" highLowerBound="80" />
</logging>
<php>
</php>
</phpunit>
/测试/特性
/测试/单元
/应用
我也试过设置
processUncoveredFilesFromWhitelist
而不是
从白名单添加未覆盖文件
但是仍然存在相同的错误您需要配置白名单,这是一个phpunit设置,请参见我遇到了相同的问题。这可能会有帮助 首先,确保可以在命令行上运行代码覆盖率 然后,看看Phpstorm试图运行什么命令。它在测试输出的第二行给出:
Testing started at 16:44 ...
C:\...\php.exe -dxdebug.coverage_enable=1 C:/.../vendor/phpunit/phpunit/phpunit --coverage-clover C:\.\XXX.xml --no-configuration --filter "/(::XXX)( .*)?$/" App\XxxTest C:\XXX.php --teamcity
PHPUnit 7.3.3 by Sebastian Bergmann and contributors.
Error: No whitelist is configured, no code coverage will be generated.
我试着自己在命令行上运行它,改变路径
我注意到的是“没有配置”。这意味着它甚至没有读取我的phpunit.xml文件。要解决此问题,请设置
设置->语言和框架->Php->测试框架->phpunit.xml文件的“默认配置文件”
您可能会遇到不同的问题,但这可能会为您指明正确的方向。在下面运行命令。这对我有用。我使用的是PHP7.1、
Symfony(1.x)
和PHPUnit(5.7)
legacy版本。因此,目录结构可能因版本而异
symfony/lib> vendor/bin/phpunit --whitelist ../[valid dir name]/
--coverage-clover test.xml UnitTest ../[dir]/[file_name]
symfony/lib> vendor/bin/phpunit --whitelist ../plugins/
--coverage-clover test.xml UnitTest ../test/PluginAllTests.php
或
symfony/lib> vendor/bin/phpunit --whitelist ../tests/
--coverage-clover test.xml UnitTest ../test/PluginAllTests.php