IntelliJ 12 code coverage not working in editor for GWT Projects
Asked Answered
C

3

7

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?

Cradling answered 16/12, 2012 at 23:25 Comment(0)
C
3

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

Cradling answered 20/12, 2012 at 15:5 Comment(3)
This bug will be fixed in 12.0.2Jehoash
This bug should be fixed in IDEA 12.0.2 (EAP will be published soon, release is coming in a couple of week or so).Casual
This problem also affects normal dependencies on source code directories! I.e. when I add a directory above my sources directory as a compile dependency (Project Structure > Dependencies) the coverage results will not be displayed (neither in gutter nor full line). Also the "Coverage Summary" will show all classes twice. This problem persists in IDEA 14.0.3!Antoinetteanton
C
8

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

Casual answered 17/12, 2012 at 2:56 Comment(8)
I'm using Mac OS X and IntelliJ 12, no colored left gutter is visible, nor Colors & Fonts have any effect.Cradling
Please share a project to reproduce the problem.Casual
That's pretty interesting. I just tried with a new project and the gutter shows up. It makes me think that effectively it is a problem with my project (maven project, with multi modules). I'll try to do more investigation to find out the reason. If I can reproduce it in a mini project, I'll share. Thanks.Cradling
We tried to reimport the project from maven into a fresh intellij, and it looks like the strange behavior I posted only happen with our project. I can't figure out what is so special in our project that causes the misbehavior, since with new projects we created to reproduce the issue, everything works just fine. It looks to me that there is some hidden bug somewhere, but I can't help to spot it, yet. Thanks for your help.Cradling
Weird. If you'll manage to reproduce it, submit a bug at youtrack.jetbrains.net/issues/IDEA.Casual
It may be related to this bug (?): youtrack.jetbrains.com/issue/PY-6817 one comment mentions "If application with tests is in root of opened project, it shows coverage. When the same app is in some nested directory (ie /virtualenv/src/app/), coverage is not shown."Cradling
Update: I tried to create a mvn submodule in a mvn project and the coverage works; so for my case the problem is something different than the one spotted in the mentioned bug report.Cradling
I found the cause. I provide an answer.Cradling
C
3

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

Cradling answered 20/12, 2012 at 15:5 Comment(3)
This bug will be fixed in 12.0.2Jehoash
This bug should be fixed in IDEA 12.0.2 (EAP will be published soon, release is coming in a couple of week or so).Casual
This problem also affects normal dependencies on source code directories! I.e. when I add a directory above my sources directory as a compile dependency (Project Structure > Dependencies) the coverage results will not be displayed (neither in gutter nor full line). Also the "Coverage Summary" will show all classes twice. This problem persists in IDEA 14.0.3!Antoinetteanton
R
1

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.

Ragtime answered 22/5, 2014 at 10:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.