7
我在其上构建以下方式在项目中设置的PHPUnit:PHPUnit的白名单和黑名单似乎被忽略
- build
- src
- service # PHP source code files here
- tests
- php
- unit # PHP unit tests here
- bootstrap.php # PHP unit tests here
- services
- MyTest.php
- ...
- vendor
我创建了以下PHPUnit的配置文件,该文件位于项目的根目录:
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.4/phpunit.xsd"
bootstrap="tests/php/unit/bootstrap.php"
verbose="true">
<testsuites>
<testsuite name="services">
<directory>tests/php/unit/services</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory>src/service</directory>
</whitelist>
</filter>
<logging>
<log type="coverage-html" target="build/php/coverage"/>
<log type="coverage-clover" target="build/php/coverage.xml"/>
<log type="junit" target="build/php/test-results.xml"/>
</logging>
</phpunit>
我想用为了PHPUnit的白名单不进行测试外的项目PHP文件,比如那些在vendor
目录......但看代码覆盖率报告,似乎白名单不被考虑在内:
可以看出在捕捉tests
和vendor
写为0%覆盖,虽然他们不应该被分析,因为它们不属于白名单。 src
目录的“2%文件”对应于我所写的唯一测试,因此代码覆盖率似乎对于此测试是正确的。
我该如何才能让src/service
真的成为唯一要分析的目录来计算代码覆盖率?
我使用PHP 5.4.3和PHPUnit 4.4.5。
将'vendor'中的文件报告为'0%'意味着它们被忽略。 IDE是否将其中的任何一个报告为拥有多于'0%'的行?我猜不会。 – axiac