Search code examples
ideintellij-ideacode-coverageemma

IntelliJ 12 code coverage not working in editor for GWT Projects


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?


Solution

  • 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