BAEL-6864 Code for the Maven Multi-Module Project Coverage with Jacoco article
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.baeldung.jacoco-coverage-aggregation</groupId>
|
||||
<artifactId>services</artifactId>
|
||||
<name>services</name>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>jacoco-coverage-aggregation</artifactId>
|
||||
<version>1.0</version>
|
||||
</parent>
|
||||
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-context</artifactId>
|
||||
<version>${spring-context.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-engine</artifactId>
|
||||
<version>${junit-jupiter-engine.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>3.1.2</version>
|
||||
<configuration>
|
||||
<includes>
|
||||
<include>**/*Test.java</include>
|
||||
</includes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<properties>
|
||||
<junit-jupiter-engine.version>5.9.2</junit-jupiter-engine.version>
|
||||
<spring-context.version>6.0.11</spring-context.version>
|
||||
</properties>
|
||||
|
||||
</project>
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
package com.baeldung.coverageaggregation;
|
||||
|
||||
import java.lang.String;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
class MyService {
|
||||
|
||||
String unitTestedOnly() {
|
||||
return "unit tested only";
|
||||
}
|
||||
|
||||
String coveredByUnitAndIntegrationTests() {
|
||||
return "covered by unit and integration tests";
|
||||
}
|
||||
|
||||
String coveredByIntegrationTest() {
|
||||
return "covered by integration test";
|
||||
}
|
||||
|
||||
String notTested() {
|
||||
return "not tested";
|
||||
}
|
||||
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
package com.baeldung.coverageaggregation;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
class MyServiceUnitTest {
|
||||
|
||||
MyService myService = new MyService();
|
||||
|
||||
@Test
|
||||
void whenUnitTestedOnly_thenCorrectText() {
|
||||
assertEquals("unit tested only", myService.unitTestedOnly());
|
||||
}
|
||||
|
||||
@Test
|
||||
void whenTestedMethod_thenCorrectText() {
|
||||
assertEquals("covered by unit and integration tests", myService.coveredByUnitAndIntegrationTests());
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user