首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >生成以Clover格式编写的代码覆盖报告.致命错误:无法重新声明preprocessGrammar()

生成以Clover格式编写的代码覆盖报告.致命错误:无法重新声明preprocessGrammar()
EN

Stack Overflow用户
提问于 2021-11-22 06:56:34
回答 1查看 1.1K关注 0票数 0

我遇到了错误:生成的代码覆盖报告格式为Clover格式。致命错误:无法重新声明/app/vendor/nikic/php-parser/grammar/phpyLang.php:22) ()(以前在第22行的/app/vendor/nikic/php-parser/grammar/phpyLang.php中用preprocessGrammar()声明)

代码语言:javascript
复制
<?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>

只有在使用测试覆盖率时才会出现此错误。

EN

回答 1

Stack Overflow用户

发布于 2021-11-22 06:56:34

我的错误就在这里:

代码语言:javascript
复制
<include>
    <directory suffix=".php">.</directory>
</include>

我想涵盖所有的文件,它们在src和项目的根目录中。

根目录中有tests,它们被包含在测试覆盖率中。它进行了递归调用。

为了解决这个问题,我设置了具体目录(src)和文件(.php-cs-fixer.)。我使用了这一指令:

代码语言:javascript
复制
<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>指令对我来说并不适用。

我最后的配置。

代码语言:javascript
复制
<?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>
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70061950

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档