我创建了一个小包,我想获得一些资格。所以其中之一就是Scrutinizer覆盖率和代码质量。在本教程中,我创建了一个文件,并将其重命名为scrutinizer.yml,并将以下内容放入其中:
build:
tests:
override:
-
command: 'vendor/bin/phpunit --coverage-clover=some-file'
coverage:
file: 'some-file'
format: 'clover'但是在我的Scrutinizer资料中同步之后,我得到了这个“覆盖率%”
那么我该怎么做呢?
发布于 2018-04-22 14:25:18
我找到了。这与PHPUnit的设置有关。我创建了一个文件,并将其重命名为phpunit.xml,并将以下配置代码放入其中。
<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之后,它给了我以下错误:
Error: No code coverage driver is available我稍微搜索了一下,发现必须在phpunit.xml中插入以下代码
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">src</directory>
</whitelist>
</filter>所以最终的phpunit.xml文件是
<?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>https://stackoverflow.com/questions/49956229
复制相似问题