Skip to content

Code Coverage with Jacoco

Somkiat Puisungnoen edited this page Dec 7, 2023 · 1 revision

Apache Maven

Edit in file pom.xml

<build>
	<plugins>
		<plugin>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-maven-plugin</artifactId>
		</plugin>
		<plugin>
			<groupId>org.jacoco</groupId>
			<artifactId>jacoco-maven-plugin</artifactId>
			<version>0.8.11</version>
			<executions>
				<execution>
					<goals>
						<goal>prepare-agent</goal>
					</goals>
				</execution>
				<execution>
					<id>report</id>
					<phase>prepare-package</phase>
					<goals>
						<goal>report</goal>
					</goals>
				</execution>
			</executions>
		</plugin>
	</plugins>
</build>

Gradle

Edit in file build.gradle

plugins {
	id 'jacoco'	
}
jacocoTestReport {
	reports {
		xml.enabled false
		csv.enabled false
		html.destination file("${buildDir}/jacocoHtml")
	}
}