Eclemma always reporting 0% of code coverage

renanleandrof picture renanleandrof · Dec 18, 2012 · Viewed 18.4k times · Source

I have a Maven test project for my application.

The JUnit tests run fine, and the code coverage test run too.

But the report always shows 0% of code coverage.

What should i do?

Answer

Joao Piccinini picture Joao Piccinini · Jan 2, 2013

According to the official site, Eclemma is a code coverage plugin for Eclipse, based on JaCoCo library.

As you want to use the same code coverage engine outside eclipse, you should include the plugin Jacoco inside the Maven configuration (pom) of your project, as the following (this code was copied from the Agile Engineering blog):

<build>
    <plugins>
        <plugin>
            <groupId>org.jacoco</groupId>
            <artifactId>jacoco-maven-plugin</artifactId>
            <version>0.6.0.201210061924</version>
            <executions>
                <execution>
                    <id>jacoco-initialize</id>
                    <goals>
                        <goal>prepare-agent</goal>
                    </goals>
                </execution>
                <execution>
                    <id>jacoco-site</id>
                    <phase>test</phase>
                    <goals>
                        <goal>report</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

To run the tests just type the following on the command line tool:

mvn clean test

p.s.: you also could use other code coverage plugins like Cobertura or Emma.