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

╄→гoц情女王★ 提交于 2019-12-23 06:48:09

问题


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.


回答1:


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

phpunit --configuration new.xml



回答2:


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/master/ChangeLog-4.8.md




回答3:


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.



来源:https://stackoverflow.com/questions/3789111/is-there-a-way-to-disable-code-coverage-in-phpunit-for-a-single-test

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!