namespaced code not included in coverage

2019-07-22 12:41发布

here is phpunit.xml :

<phpunit
        bootstrap="bootstrap.php"
        colors="false"
        convertErrorsToExceptions="true"
        convertNoticesToExceptions="true"
        convertWarningsToExceptions="true"
        stopOnFailure="false"
        stopOnError="false"
        stopOnIncomplete="false"
        stopOnSkipped="false">

    <filter>
        <whitelist processUncoveredFilesFromWhitelist="true">
            <directory suffix=".php">../modules</directory>
            <directory suffix=".php">../models</directory>
            <directory suffix=".php">../lib</directory>
            <directory suffix=".php">../components</directory>
            <exclude>
                <directory suffix=".php">../modules/*/views</directory>
                <directory suffix=".php">../modules/*/widgets</directory>
                <directory suffix=".php">../modules/*/controllers</directory>
                <directory suffix=".php">../modules/ClaimProfile</directory>
                <directory suffix=".php">../modules/SocialNetworks</directory>
            </exclude>
        </whitelist>
    </filter>

    <logging>
        <log type="coverage-clover" target="build/logs/clover.xml" />
        <log type="junit" target="build/logs/junit.xml" logIncompleteSkipped="true" />
    </logging>
</phpunit>

and the resulting clover.xml does include information for namespaced classes and all but Jenkin's PHP-Clover plug-in keeps reporting coverage that disregards code that is inside a namespace. (i.e. none of source files that define namespaces are shown in the report but files with code that falls totally in the global namespace appear in the list).

1条回答
一夜七次
2楼-- · 2019-07-22 13:06

Eventually ran into the same problem. Turned out that Jenkins Clover PHP Plugin contains an error here:

https://github.com/jenkinsci/cloverphp-plugin/blob/master/src/main/java/org/jenkinsci/plugins/cloverphp/CloverCoverageParser.java

As one can easily see, Clover Coverage Parser parses coverage/project, coverage/project/file and coverage/project/file/class objects. It ignores coverage/project/package (and everything inside ).

This can be easily fixed by plugin maintainer.

查看更多
登录 后发表回答