Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any way to show lines covered by unit tests on the editor view in IntelliJ Idea?

I am aware you can configure Idea to show the test coverage in a separate view, but is there any way to show the coverage in the main editor screen.

For example, I see the line numbers on the left, with a little green or red number in [] giving the number of unit tests run against this line.

Possibly something similar to the editor section (of Eclipse) shown here - http://www.copperykeenclaws.com/wp-content/uploads/2010/10/emma_eclipse2.png.

Is this possible? Is there a plugin to achieve this?

I'm using the IntelliJ coverage tool, and Idea 12.0.4 (build 129.549)

Thanks

like image 866
GKelly Avatar asked Jun 05 '13 15:06

GKelly


People also ask

What is code coverage in IntelliJ?

Code coverage. Code coverage in IntelliJ IDEA allows you to see the extent to which your code has been executed. It also lets you verify the extent to which your code is covered by unit tests, so that you can estimate how effective these tests are. Code coverage is supported only for the classes and sources that belong to your current project.

Does this component have 0% unit test coverage?

The truth is that this component has 0% unit test coverage. Here we start to see how we can misinterpret the meaning of a code-coverage report. The report only shows us what lines were executed, not what lines were tested. In Angular, when you compile a component in a unit test ngOnInit and everything it calls will get “covered” immediately.

What is Emma in IntelliJ?

IntelliJ IDEA code coverage runner (recommended) EMMA is an open-source toolkit. Note that EMMA is not supported by the author any more, and works with Java 7 only when frame validation is turned off (pass -noverify to the process).


1 Answers

As @maba linked to, you can turn this on in intellij. Here's a link from his link that gives much more thorough information about it.

enable code coverage

This is what it will look like when it's turned on:

enter image description here

like image 155
Daniel Kaplan Avatar answered Nov 15 '22 07:11

Daniel Kaplan