首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在检查器中生成代码覆盖率

在检查器中生成代码覆盖率
EN

Stack Overflow用户
提问于 2018-04-21 21:24:21
回答 1查看 548关注 0票数 2

我创建了一个小包,我想获得一些资格。所以其中之一就是Scrutinizer覆盖率和代码质量。在本教程中,我创建了一个文件,并将其重命名为scrutinizer.yml,并将以下内容放入其中:

代码语言:javascript
复制
build:
tests:
    override:
        -
            command: 'vendor/bin/phpunit --coverage-clover=some-file'
            coverage:
                file: 'some-file'
                format: 'clover'

但是在我的Scrutinizer资料中同步之后,我得到了这个“覆盖率%”

那么我该怎么做呢?

EN

回答 1

Stack Overflow用户

发布于 2018-04-22 14:25:18

我找到了。这与PHPUnit的设置有关。我创建了一个文件,并将其重命名为phpunit.xml,并将以下配置代码放入其中。

代码语言:javascript
复制
<phpunit backupGlobals="false"
     backupStaticAttributes="false"
     colors="true"
     convertErrorsToExceptions="true"
     convertNoticesToExceptions="true"
     convertWarningsToExceptions="true"
     processIsolation="false"
     stopOnFailure="false"
     syntaxCheck="false"
>
<testsuites>
    <testsuite name="Package Test Suite">
        <directory suffix=".php">./tests/</directory>
    </testsuite>
</testsuites>
</phpunit>

在运行一个创建本地coverage.xml文件的phpunit之后,它给了我以下错误:

代码语言:javascript
复制
Error:         No code coverage driver is available

我稍微搜索了一下,发现必须在phpunit.xml中插入以下代码

代码语言:javascript
复制
<filter>
    <whitelist processUncoveredFilesFromWhitelist="true">
        <directory suffix=".php">src</directory>
    </whitelist>
</filter>

所以最终的phpunit.xml文件是

代码语言:javascript
复制
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
         backupStaticAttributes="false"
         colors="true"
         convertErrorsToExceptions="true"
         convertNoticesToExceptions="true"
         convertWarningsToExceptions="true"
         processIsolation="false"
         stopOnFailure="false"
         syntaxCheck="false"
>
    <testsuites>
        <testsuite name="Package Test Suite">
            <directory suffix=".php">./tests/</directory>
        </testsuite>
    </testsuites>

    <filter>
        <whitelist processUncoveredFilesFromWhitelist="true">
            <directory suffix=".php">src</directory>
        </whitelist>
    </filter>
</phpunit>
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/49956229

复制
相关文章

相似问题

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