Skip to content

Commit 0b6bd18

Browse files
committed
test: generate code coverage report for tests
test coverage for builders package was 0% it's now 24% Signed-off-by: Dale Lane <dale.lane@uk.ibm.com>
1 parent 629f0e4 commit 0b6bd18

File tree

1 file changed

+89
-1
lines changed

1 file changed

+89
-1
lines changed

pom.xml

Lines changed: 89 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,19 +99,25 @@
9999
<target>1.8</target>
100100
</configuration>
101101
</plugin>
102+
103+
<!-- run unit tests -->
102104
<plugin>
103105
<artifactId>maven-surefire-plugin</artifactId>
104106
<version>3.0.0-M7</version>
105107
<configuration>
108+
<argLine>${surefire.jacoco.args}</argLine>
106109
<systemPropertyVariables>
107110
<connectorVersion>${project.version}</connectorVersion>
108111
</systemPropertyVariables>
109112
</configuration>
110113
</plugin>
114+
115+
<!-- run integration tests -->
111116
<plugin>
112117
<artifactId>maven-failsafe-plugin</artifactId>
113118
<version>3.0.0-M7</version>
114119
<configuration>
120+
<argLine>${failsafe.jacoco.args}</argLine>
115121
<systemPropertyVariables>
116122
<connectorVersion>${project.version}</connectorVersion>
117123
</systemPropertyVariables>
@@ -126,6 +132,8 @@
126132
</execution>
127133
</executions>
128134
</plugin>
135+
136+
<!-- build the release jar -->
129137
<plugin>
130138
<artifactId>maven-assembly-plugin</artifactId>
131139
<version>3.1.1</version>
@@ -144,7 +152,6 @@
144152
</configuration>
145153
</plugin>
146154

147-
148155
<!-- add the src/integration folder as a test folder, which lets us keep -->
149156
<!-- tests that have a dependency on testcontainers separate from pure -->
150157
<!-- unit tests with no external dependency -->
@@ -167,6 +174,87 @@
167174
</execution>
168175
</executions>
169176
</plugin>
177+
178+
<!-- generate test code coverage report -->
179+
<plugin>
180+
<groupId>org.jacoco</groupId>
181+
<artifactId>jacoco-maven-plugin</artifactId>
182+
<version>0.8.8</version>
183+
<executions>
184+
<execution>
185+
<id>before-unit-test-execution</id>
186+
<goals>
187+
<goal>prepare-agent</goal>
188+
</goals>
189+
<configuration>
190+
<destFile>${project.build.directory}/jacoco-output/jacoco-unit-tests.exec</destFile>
191+
<propertyName>surefire.jacoco.args</propertyName>
192+
</configuration>
193+
</execution>
194+
<execution>
195+
<id>after-unit-test-execution</id>
196+
<phase>test</phase>
197+
<goals>
198+
<goal>report</goal>
199+
</goals>
200+
<configuration>
201+
<dataFile>${project.build.directory}/jacoco-output/jacoco-unit-tests.exec</dataFile>
202+
<outputDirectory>${project.reporting.outputDirectory}/jacoco-unit-test-coverage-report</outputDirectory>
203+
</configuration>
204+
</execution>
205+
<execution>
206+
<id>before-integration-test-execution</id>
207+
<phase>pre-integration-test</phase>
208+
<goals>
209+
<goal>prepare-agent</goal>
210+
</goals>
211+
<configuration>
212+
<destFile>${project.build.directory}/jacoco-output/jacoco-integration-tests.exec</destFile>
213+
<propertyName>failsafe.jacoco.args</propertyName>
214+
</configuration>
215+
</execution>
216+
<execution>
217+
<id>after-integration-test-execution</id>
218+
<phase>post-integration-test</phase>
219+
<goals>
220+
<goal>report</goal>
221+
</goals>
222+
<configuration>
223+
<dataFile>${project.build.directory}/jacoco-output/jacoco-integration-tests.exec</dataFile>
224+
<outputDirectory>${project.reporting.outputDirectory}/jacoco-integration-test-coverage-report</outputDirectory>
225+
</configuration>
226+
</execution>
227+
<execution>
228+
<id>merge-unit-and-integration</id>
229+
<phase>post-integration-test</phase>
230+
<goals>
231+
<goal>merge</goal>
232+
</goals>
233+
<configuration>
234+
<fileSets>
235+
<fileSet>
236+
<directory>${project.build.directory}/jacoco-output/</directory>
237+
<includes>
238+
<include>*.exec</include>
239+
</includes>
240+
</fileSet>
241+
</fileSets>
242+
<destFile>${project.build.directory}/jacoco-output/merged.exec</destFile>
243+
</configuration>
244+
</execution>
245+
<execution>
246+
<id>create-merged-report</id>
247+
<phase>post-integration-test</phase>
248+
<goals>
249+
<goal>report</goal>
250+
</goals>
251+
<configuration>
252+
<dataFile>${project.build.directory}/jacoco-output/merged.exec</dataFile>
253+
<outputDirectory>${project.reporting.outputDirectory}/jacoco-merged-test-coverage-report</outputDirectory>
254+
</configuration>
255+
</execution>
256+
</executions>
257+
</plugin>
170258
</plugins>
171259
</build>
172260
</project>

0 commit comments

Comments
 (0)