Jacoco - SirajChaudhary/comprehensive-example-on-microservices-using-spring-boot-with-spring-cloud GitHub Wiki

Code Coverge: Industry benchmark for code coverage is 80%

How to run Code Coverge

Step1: Add Jacoco plugin in pom.xml and exclude packages which you don't want to be executed for code coverage.

<!-- Jacoco plug-in for Code Coverage -->
<plugin>
	<groupId>org.jacoco</groupId>
	<artifactId>jacoco-maven-plugin</artifactId>
	<version>0.8.7</version>
	<configuration>
		<!-- packages and classes which we don't want to include in Code Coverage -->
		<excludes>
			<exclude>**/com/airport/pilot/service/**</exclude>
			<exclude>**/com/airport/pilot/exception/**</exclude>
			<exclude>**/com/airport/pilot/response/**</exclude>
			<exclude>**/com/airport/pilot/entity/**</exclude>
			<exclude>**/com/airport/pilot/AirportPilotServiceApplication.class</exclude>
		</excludes>
	</configuration>
	<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>
<!-- Jacoco plug-in for Code Coverage -->

Step2: Run

* mvn test 
* mvn verify

Step3: Visit URL for code coverage

${YOUR_PROJECT_WORKSPACE}/microservices-using-spring-boot-with-spring-cloud/airport-pilotservice/target/site/jacoco/index.html

⚠️ **GitHub.com Fallback** ⚠️