Skip to content

Commit d3fbce3

Browse files
Copilotbrunoborges
andcommitted
Add JaCoCo test coverage plugin with custom configuration
Co-authored-by: brunoborges <129743+brunoborges@users.noreply.github.com>
1 parent 2e12f95 commit d3fbce3

1 file changed

Lines changed: 58 additions & 0 deletions

File tree

pom.xml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@
4242
<!-- Directory where the copilot-sdk repo will be cloned for tests -->
4343
<copilot.sdk.clone.dir>${project.build.directory}/copilot-sdk</copilot.sdk.clone.dir>
4444
<copilot.tests.dir>${copilot.sdk.clone.dir}/test</copilot.tests.dir>
45+
<!-- Test coverage output locations -->
46+
<coverage.reports.dir>${project.build.directory}/coverage-reports</coverage.reports.dir>
4547
</properties>
4648

4749
<dependencies>
@@ -212,6 +214,8 @@
212214
<artifactId>maven-surefire-plugin</artifactId>
213215
<version>3.5.4</version>
214216
<configuration>
217+
<!-- Inject JaCoCo agent for coverage collection during test runs -->
218+
<argLine>${testExecutionAgentArgs}</argLine>
215219
<systemPropertyVariables>
216220
<copilot.tests.dir>${copilot.tests.dir}</copilot.tests.dir>
217221
<copilot.sdk.dir>${copilot.sdk.clone.dir}</copilot.sdk.dir>
@@ -237,6 +241,47 @@
237241
</java>
238242
</configuration>
239243
</plugin>
244+
<!-- Coverage tracking for CopilotClient/CopilotSession interactions with CLI -->
245+
<plugin>
246+
<groupId>org.jacoco</groupId>
247+
<artifactId>jacoco-maven-plugin</artifactId>
248+
<version>0.8.12</version>
249+
<executions>
250+
<!-- Instrument bytecode before E2ETestContext runs tests with CapiProxy -->
251+
<execution>
252+
<id>wire-up-coverage-instrumentation</id>
253+
<goals>
254+
<goal>prepare-agent</goal>
255+
</goals>
256+
<configuration>
257+
<!-- Store exec file alongside other build artifacts -->
258+
<destFile>${project.build.directory}/jacoco-test-results/sdk-tests.exec</destFile>
259+
<!-- Pass agent args via this property to surefire -->
260+
<propertyName>testExecutionAgentArgs</propertyName>
261+
<!-- Focus on SDK package, exclude test harness utilities -->
262+
<includes>
263+
<include>com/github/copilot/sdk/**</include>
264+
</includes>
265+
<excludes>
266+
<exclude>com/github/copilot/sdk/E2ETestContext*</exclude>
267+
<exclude>com/github/copilot/sdk/CapiProxy*</exclude>
268+
</excludes>
269+
</configuration>
270+
</execution>
271+
<!-- Generate HTML/XML reports after tests complete -->
272+
<execution>
273+
<id>build-coverage-report-from-tests</id>
274+
<goals>
275+
<goal>report</goal>
276+
</goals>
277+
<phase>verify</phase>
278+
<configuration>
279+
<dataFile>${project.build.directory}/jacoco-test-results/sdk-tests.exec</dataFile>
280+
<outputDirectory>${project.reporting.outputDirectory}/jacoco-coverage</outputDirectory>
281+
</configuration>
282+
</execution>
283+
</executions>
284+
</plugin>
240285
<plugin>
241286
<groupId>org.apache.maven.plugins</groupId>
242287
<artifactId>maven-checkstyle-plugin</artifactId>
@@ -366,6 +411,19 @@
366411
</reportSet>
367412
</reportSets>
368413
</plugin>
414+
<!-- Test coverage for CopilotClient, CopilotSession, JsonRpcClient and supporting classes -->
415+
<plugin>
416+
<groupId>org.jacoco</groupId>
417+
<artifactId>jacoco-maven-plugin</artifactId>
418+
<version>0.8.12</version>
419+
<reportSets>
420+
<reportSet>
421+
<reports>
422+
<report>report</report>
423+
</reports>
424+
</reportSet>
425+
</reportSets>
426+
</plugin>
369427
</plugins>
370428
</reporting>
371429

0 commit comments

Comments
 (0)