Skip to content
This repository was archived by the owner on Nov 20, 2021. It is now read-only.

Code Coverage

PINGUET Julien edited this page Sep 20, 2015 · 2 revisions

Definitition

"Code coverage is a measure used to describe the degree to which the source code of a program is tested by a particular test suite." WikiPedia

Utils

Cobertura

This popular tool is not supported by Java 8:

  • work with Eclipse
  • not work with Maven

Eclipse

Plugin: eCobertura (Eclipse addon)

Require: JVM option -noverify

Maven

<project>
	<properties>
		<cobertura.version>2.7</cobertura.version>
	</properties>

	<build>
		<plugins>
			<plugin>
				<groupId>org.codehaus.mojo</groupId>
				<artifactId>cobertura-maven-plugin</artifactId>
				<version>${cobertura.version}</version>
			</plugin>
		</plugins>
	</build>

	<reporting>
		<plugins>
			<plugin>
				<groupId>org.codehaus.mojo</groupId>
				<artifactId>cobertura-maven-plugin</artifactId>
				<version>${cobertura.version}</version>
			</plugin>
		</plugins>
	</reporting>
</project>

Run : mvn cobertura:cobertura

JaCoCo (By EclEmma)

Eclipse

Plugin: EclEmma Java Code Coverage

Maven

<project>
    <build>
        <plugins>
            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <version>${jacoco.version}</version>
            </plugin>
        </plugins>
    </build>
</project>

Clone this wiki locally