Question

I'm trying IntelliJ 12, and I can't manage to get the line colored (red, green, yellow) in the editors after running the tests with coverage. Did anybody noticed the problem or it's just me not being able to make it work?

Was it helpful?

Solution 2

Finally I found out what was causing IntelliJ IDEA 12.0.0 (and also 12.0.1) to malfunction the code coverage.

My project is a GWT project, so there is some additional configuration to run the gwt client tests: the source directories are added in the classpath so that the gwt devmode can be ran headless to be tested:

 <build>
        <plugins>
            <plugin>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.5</version>
                <configuration>
                    <additionalClasspathElements>
                        <!-- the following two lines, causes intellij coverage to stop working -->
                        <additionalClasspathElement>${project.build.sourceDirectory}</additionalClasspathElement>
                        <additionalClasspathElement>${project.build.testSourceDirectory}</additionalClasspathElement>
                    </additionalClasspathElements>
                </configuration>
            </plugin>
        </plugins>
    </build>

Adding the source folders to the classpath of surefire causes IntelliJ IDEA 12.x to misconfigure the project (the .iml file) and the coverage stops working.

Notice that this maven configuration doesn't have any impact in IntelliJ IDEA 11.x, that works perfectly.

To reproduce the bug, just add the <additionalClasspathElement> to your surefire configuration, then rightclick on your project and do a "Maven->Reimport", then run the tests with coverage; and you'll see that the editor misses all informations about the lines coverage.

I managed to reproduce the issue, and I am going to submit the bug report.

The workaround would be to comment out the two lines of <additionalClasspathElement> and do a "Maven->Reimport", then uncomment those if you need.

Bug reported IDEA-97920, it'll be fixed in 12.0.2

OTHER TIPS

By default code coverage results are displayed only in the left gutter and may be hard to notice:

coverage displayed in gutter

You can either change the gutter colors or configure IntelliJ IDEA to change the background of the whole lines (instead of the foreground) depending on their coverage status:

coverage background settings

Now it's much easier to see the coverage status:

coverage displayed as background

I'm using IntelliJ 13 on a Mac with the Darcula theme.

I did not notice the green/red colours at first as they are very dull and don't stand out from the black background.

However if you look very carefully in the lefthand on the left of the line numbers (if you have them configured) you will see them faintly.

You can easily configure the colours to make them more noticeable.

The defaults ought to be changed by IntelliJ in a future release.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top