Generating Code Coverage in scrutinizer

727 Views Asked by At

I created a little package and I want to get some qualifications for it. So one of them is Scrutinizer Coverage and Code Quality. As in the tutorial I created a file and renamed it to scrutinizer.yml and put the following into it:

build:
tests:
    override:
        -
            command: 'vendor/bin/phpunit --coverage-clover=some-file'
            coverage:
                file: 'some-file'
                format: 'clover'

But after syncing in my Scrutinizer profile I get this "coverage NaN%"

So what should I do?

1

There are 1 best solutions below

0
On

I found it. it related to setting of PHPUnit. i create a file and renamed it to phpunit.xml and put following configuration code to it.

<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>

and after a ran phpunit for create local coverage.xml file; it given to me following error:

Error:         No code coverage driver is available

and i after a little search it found i have to insert following code into phpunit.xml

<filter>
    <whitelist processUncoveredFilesFromWhitelist="true">
        <directory suffix=".php">src</directory>
    </whitelist>
</filter>

so final phpunit.xml file is

<?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>