“没有配置白名单......”。但那不是真的。 <whitelist>在Symfony app \ phpunit.xml.dist中定义。 (此错误仅在Netbeans中发生,而不在cmd中发生)

时间:2016-05-26 22:07:43

标签: symfony netbeans phpunit

(我是PHPUnit的初学者)

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

def split_dict(cell, keys, default_value = None):
    value_tuple = [cell[y] if y in cell else default_value for y in keys]
    return pd.Series( value_tuple, index = keys)

ds_dict = ds.map(json.loads)
ds_dict.apply(lambda ds: split_dict(ds, ["a", "b", "c"]))

但是我的Symfony默认app \ phpunit.xml.dist定义了"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.

<whitelist>

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

修改

但是在windows console命令中 <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> 效果很好,可以产生报道。

1 个答案:

答案 0 :(得分:4)

不幸的是&#34;没有配置白名单,不会生成代码覆盖率&#34;如果白名单配置无效,也会打印消息,有关详细信息,请参阅https://github.com/sebastianbergmann/phpunit/issues/2049