错误:"未配置白名单,不会生成代码覆盖率"在尝试运行PHPUnit代码覆盖时,仅在不在cmd中的Netbeans中发生

时间:2016-05-27 17:42:59

标签: netbeans

在Netbeans中,我尝试在Symfony2.8项目中编写代码覆盖PHPUnit,但它会抛出错误:

"C:\wamp\www\treningPHPUnitSymfony2.8\bin\phpunit.bat" "--colors" "--log-junit" "C:\Users\chiny\AppData\Local\Temp\nb-phpunit-log.xml" "--coverage-clover" "C:\Users\chiny\AppData\Local\Temp\nb-phpunit-coverage.xml" "C:\Program Files\NetBeans 8.1\php\phpunit\NetBeansSuite.php" "--" "--run=C:\wamp\www\treningPHPUnitSymfony2.8\src\TreningBundle\Tests\Utils\CalculatorTest.php"
PHPUnit 5.3.4 by Sebastian Bergmann and contributors.

Error:         No whitelist configured, no code coverage will be generated

................I                                                17 / 17 (100%)

Time: 531 ms, Memory: 4.00MB

OK, but incomplete, skipped, or risky tests!
Tests: 17, Assertions: 16, Incomplete: 1.
Done.

但是我的Symfony默认app \ phpunit.xml.dist定义了<whitelist>

<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.8/phpunit.xsd"
         backupGlobals="false"
         colors="true"
         bootstrap="autoload.php"
>
    <php>
        <ini name="error_reporting" value="-1" />
        <!--
            <server name="KERNEL_DIR" value="/path/to/your/app/" />
        -->
    </php>

    <testsuites>
        <testsuite name="Project Test Suite">
            <directory>../src/*/*Bundle/Tests</directory>
            <directory>../src/*/Bundle/*Bundle/Tests</directory>
            <directory>../src/*Bundle/Tests</directory>
        </testsuite>
    </testsuites>

    <filter>
        <whitelist>
            <directory>../src</directory>
            <exclude>
                <directory>../src/*Bundle/Resources</directory>
                <directory>../src/*Bundle/Tests</directory>
                <directory>../src/*/*Bundle/Resources</directory>
                <directory>../src/*/*Bundle/Tests</directory>
                <directory>../src/*/Bundle/*Bundle/Resources</directory>
                <directory>../src/*/Bundle/*Bundle/Tests</directory>
            </exclude>
        </whitelist>
    </filter>
</phpunit>

但是在windows console命令中 phpunit -c app/ src/TreningBundle/ --coverage-html=cov/效果很好,可以产生报道。

我得到了: Symfony2.8,PHPUnit5.3.4,Netbeans 8.1

0 个答案:

没有答案