smi*_*eua 6 phpunit code-coverage clover
我为什么需要这个?我在symfony项目上运行测试(并使用Zend fw),phpunit为所有受影响的文件生成三叶草.但我不希望看到symfony和Zend libs(以及所有其他第三方)的报道.我希望只看到我的代码的报道.或者可能这应该做三叶草查看器?我正在使用hudson的clover插件,但它不支持查看特定来源.三叶草插件显示,我的代码只覆盖了20%,这是不正确的,因为它也考虑了symfony和Zend库.
顺便说一下,可能还有另外一种方法可以解决这个问题吗?
Ant*_*nna 10
您需要为phpunit创建配置文件,在该配置文件中,您可以从代码覆盖中排除特定文件或目录.
示例文件如下所示:
<phpunit stopOnFailure="false">
<testsuite name="Name">
</testsuite>
<filter>
<whitelist>
<directory suffix=".php">../php</directory>
<exclude>
<file>../php/somefile.php</file>
<directory suffix=".php">../php/pdf</directory>
</exclude>
</whitelist>
</filter>
<logging>
<log type="coverage-html" target="target-dir/coverage" charset="UTF-8" yui="true" highlight="true"/>
<log type="coverage-clover" target="target-dir/build/logs/clover.xml"/>
</logging>
</phpunit>
Run Code Online (Sandbox Code Playgroud)
使用上面的文件,除了文件../php/somefile.php和所有带扩展名的文件外,代码覆盖率中包含了../php下的所有内容(这是从测试所在的目录和执行phprun的相对位置).目录中的php ../php/pdf
将此文件命名为phpunit.xml,将其放入运行测试的同一目录中.他们,如果你运行phpunit,它会选择conf.
如果您不能使用此特定文件名,则可以从命令行指定名称
phpunit --configuration yourconf.xml
Run Code Online (Sandbox Code Playgroud)
有关phpunit配置文件的更多详细信息,请访问:http://phpunit.de/manual/3.7/en/appendixes.configuration.html
归档时间: |
|
查看次数: |
3725 次 |
最近记录: |