Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 399
Eugene M Avatar asked Sep 24 '10 16:09

Eugene M


People also ask

How do I turn off code coverage?

To disable code coverage highlightingIn the Code Coverage Suites dialog, choose No coverage.

What is code coverage in Phpunit?

In computer science, code coverage is a measure used to describe the degree to which the source code of a program is tested by a particular test suite. A program with high code coverage has been more thoroughly tested and has a lower chance of containing software bugs than a program with low code coverage.

How do I configure code coverage?

Configure coveragePress Ctrl+Alt+S to open the IDE settings and select Build, Execution, Deployment | Coverage. Define how the collected coverage data will be processed: Show options before applying coverage to the editor: show the Code Coverage dialog every time you run a new run configuration with code coverage.


2 Answers

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

like image 154
Gonçalo Queirós Avatar answered Oct 12 '22 22:10

Gonçalo Queirós


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

phpunit --configuration new.xml 
like image 35
Alex Howansky Avatar answered Oct 12 '22 23:10

Alex Howansky