PHPUnit不生成clover.xml报告文件

时间:2016-06-22 07:48:38

标签: jenkins phpunit php-7 clover

这些是我的配置:

phpunit.xml

    <!-- http://phpunit.de/manual/4.1/en/appendixes.configuration.html -->
    <phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.1/phpunit.xsd"
             backupGlobals="false"
             colors="true"
             bootstrap="../usr/core/autoload.test.php"
    >
        <php>
            <ini name="error_reporting" value="-1" />
            <server name="KERNEL_DIR" value="usr/core/" />
        </php>

        <testsuites>
            <testsuite name="Api">
                <directory>../usr/Project/Api/*Bundle/Tests</directory>
            </testsuite>
            <testsuite name="Backend">
                <directory>../usr/Project/Backend/*Bundle/Tests</directory>
            </testsuite>
            <testsuite name="CMS">
                <directory>../usr/Project/CMS/*Bundle/Tests</directory>
            </testsuite>
            <testsuite name="Console">
                <directory>../usr/Project/Console/*Bundle/Tests</directory>
            </testsuite>
            <testsuite name="Im">
                <directory>../usr/Project/Im/*Bundle/Tests</directory>
            </testsuite>
            <testsuite name="Library">
                <directory>../usr/Project/Library/*Bundle/Tests</directory>
            </testsuite>
            <testsuite name="Registration">
                <directory>../usr/Project/Registration/*Bundle/Tests</directory>
            </testsuite>
            <testsuite name="TestSuite">
                <directory>../usr/tests</directory>
            </testsuite>
        </testsuites>

        <filter>
            <whitelist addUncoveredFilesFromWhitelist="true">
                <directory>usr</directory>
                <exclude>
                    <directory>../usr/*Bundle/Resources</directory>
                    <directory>../usr/*/*Bundle/Resources</directory>
                    <directory>../usr/*/Bundle/*Bundle/Resources</directory>
                </exclude>
            </whitelist>
        </filter>
    </phpunit>

和ant配置:

<target name="phpunit"
        unless="phpunit.done"
        description="Run unit tests with PHPUnit">
    <exec executable="${phpunit}" resultproperty="result.phpunit" taskname="phpunit">
        <arg value="--configuration"  path="${basedir}/build/phpunit.xml"/>
        <arg value="--coverage-clover"  path="${basedir}/build/logs/clover.xml"/>
        <arg value="--log-junit" path="${basedir}/build/logs/phpunit.xml"/>
    </exec>

    <property name="phpunit.done" value="true"/>
</target>

到目前为止一切正常。 但是当我在jenkins中执行时,我得到以下消息:

    Clover xml file does not exist in: /var/lib/jenkins/workspace/Project5FullBuild called: build/logs/clover.xml and will not be copied to: /var/lib/jenkins/jobs/Project5FullBuild/builds/39/cloverphp/clover.xml
    Could not find 'build/coverage/build/logs/clover.xml'.  Did you generate the XML report for Clover?

我检查了logs目录。 没有clover.xml存在。 我还检查了其他几个谷歌的提示,但到目前为止没有任何帮助。 我错过了什么?

2 个答案:

答案 0 :(得分:1)

如果配置文件中的whitelisting没有产生文件,据我所知,phpunit将不会生成coverage xml文件。

尝试修改过滤器元素以确保它包含文件,例如:

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

答案 1 :(得分:-1)

就我而言,必须安装php-xdebug模块,否则它将无法正常工作。