开发者

Is there a way to disable code coverage in PHPUnit for a single test?

开发者 https://www.devze.com 2023-01-17 06:29 出处:网络
Every time I run a single unit test in PHPUnit, a code coverage report is also generated. I have an older computer here at work, and if I could disable the code coverage when I don\'t need it, 开发者_

Every time I run a single unit test in PHPUnit, a code coverage report is also generated. I have an older computer here at work, and if I could disable the code coverage when I don't need it, 开发者_运维技巧that would put less strain on my CPU.

Is there a way to disable the code coverage on a per-test basis? I couldn't find any command-line switch that would do it.


Since this is one of google top results, I think it makes sense to point out that since version 4.8 PHPUnit now supports the --no-coverage option to override you xml configuration.

https://github.com/sebastianbergmann/phpunit/blob/4.8.0/ChangeLog-4.8.md


How about making a copy of your phpunit.xml, removing the <logging> stanza from it, then doing:

phpunit --configuration new.xml


You can annotate a test class or test method with @coversNothing. The test(s) then do not contribute to the code coverage report. However, code coverage data will still be collected (slowing down the execution). I plan to optimize this in the future.

0

精彩评论

暂无评论...
验证码 换一张
取 消