我遇到了错误:生成的代码覆盖报告格式为Clover格式。致命错误:无法重新声明/app/vendor/nikic/php-parser/grammar/phpyLang.php:22) ()(以前在第22行的/app/vendor/nikic/php-parser/grammar/phpyLang.php中用preprocessGrammar()声明)
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.5/phpunit.xsd"
bootstrap="vendor/autoload.php"
cacheResultFile=".phpunit.cache/test-results">
<testsuites>
<testsuite name="default">
<directory>tests</directory>
</testsuite>
</testsuites>
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">.</directory>
</include>
<report>
<clover outputFile="phpunit.coverage.xml"/>
</report>
</coverage>
<logging>
<junit outputFile="phpunit.report.xml"/>
</logging>
</phpunit>只有在使用测试覆盖率时才会出现此错误。
发布于 2021-11-22 06:56:34
我的错误就在这里:
<include>
<directory suffix=".php">.</directory>
</include>我想涵盖所有的文件,它们在src和项目的根目录中。
根目录中有tests,它们被包含在测试覆盖率中。它进行了递归调用。
为了解决这个问题,我设置了具体目录(src)和文件(.php-cs-fixer.)。我使用了这一指令:
<include>
<directory suffix=".php">src</directory>
<directory prefix=".php-cs-fixer.">.</directory>
</include>我也可以使用<file>,但是我有几个文件,并且使用directory更有用。https://phpunit.readthedocs.io/en/9.5/configuration.html#the-file-element
<exclude>指令对我来说并不适用。
我最后的配置。
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.5/phpunit.xsd"
bootstrap="vendor/autoload.php"
cacheResultFile=".phpunit.cache/test-results">
<testsuites>
<testsuite name="default">
<directory>tests</directory>
</testsuite>
</testsuites>
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">src</directory>
<directory prefix=".php-cs-fixer.">.</directory>
</include>
<report>
<clover outputFile="phpunit.coverage.xml"/>
</report>
</coverage>
<logging>
<junit outputFile="phpunit.report.xml"/>
</logging>
</phpunit>https://stackoverflow.com/questions/70061950
复制相似问题