Skip to content

Add unit tests for ToolInvocation to achieve 100% coverage#122

Merged
brunoborges merged 6 commits intomainfrom
copilot/improve-jacoco-coverage
Feb 11, 2026
Merged

Add unit tests for ToolInvocation to achieve 100% coverage#122
brunoborges merged 6 commits intomainfrom
copilot/improve-jacoco-coverage

Conversation

Copy link
Contributor

Copilot AI commented Feb 11, 2026

ToolInvocation class had 61% instruction coverage with untested getter methods and the getArgumentsAs() type-safe deserialization path.

Changes

Created ToolInvocationTest.java with unit tests covering:

  • All getter methods (getSessionId, getToolCallId, getToolName)
  • getArguments() null branch handling
  • getArgumentsAs(Class<T>) type-safe deserialization with records and POJOs
  • Error handling for invalid deserialization attempts

Result

Coverage improved to 100% instruction and branch coverage (68/68 instructions, 2/2 branches).

Example

The tests exercise type-safe argument deserialization patterns:

// Test deserialization to record
record WeatherArgs(String city, String units) {}

ObjectNode argsNode = JsonNodeFactory.instance.objectNode();
argsNode.put("city", "Paris");
argsNode.put("units", "metric");

invocation.setArguments(argsNode);
WeatherArgs args = invocation.getArgumentsAs(WeatherArgs.class);
assertEquals("Paris", args.city());

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • checkstyle.org
    • Triggering command: /opt/hostedtoolcache/CodeQL/2.24.0/x64/codeql/tools/linux64/java/bin/java /opt/hostedtoolcache/CodeQL/2.24.0/x64/codeql/tools/linux64/java/bin/java -jar /opt/hostedtoolcache/CodeQL/2.24.0/x64/codeql/xml/tools/xml-extractor.jar --fileList=/home/REDACTED/work/copilot-sdk-java/.codeql-scratch/dbs/java/working/files-to-index7452523704395560700.list --sourceArchiveDir=/home/REDACTED/work/copilot-sdk-java/.codeql-scratch/dbs/java/src --outputDir=/home/REDACTED/work/copilot-sdk-java/.codeql-scratch/dbs/java/trap/java which n-Hotspot_jdk/17.0.18-8/x64/bin/git DROP which de/node/bin/git which git b/copilot/sdk/ToolInvocationTest.java git which --show-toplevel urin-17-jdk-amd6show 4/lib/jspawnhelp6a68d9fde75e0670d1e2892ef9a287aa1ea71f41:src/test/java/com/github/copilot/sdk/ToolInvocationTest.java node (dns block)
  • https://api.github.com/copilot_internal/user
    • Triggering command: /home/REDACTED/work/copilot-sdk-java/copilot-sdk-java/target/copilot-sdk/test/harness/node_modules/@github/copilot-linux-x64/copilot /home/REDACTED/work/copilot-sdk-java/copilot-sdk-java/target/copilot-sdk/test/harness/node_modules/@github/copilot-linux-x64/copilot --server --no-auto-update --log-level info --stdio --auth-token-env COPILOT_SDK_AUTH_TOKEN --no-auto-login (http block)
    • Triggering command: /home/REDACTED/work/copilot-sdk-java/copilot-sdk-java/target/copilot-sdk/test/harness/node_modules/@github/copilot-linux-x64/copilot /home/REDACTED/work/copilot-sdk-java/copilot-sdk-java/target/copilot-sdk/test/harness/node_modules/@github/copilot-linux-x64/copilot --server --no-auto-update --log-level info --stdio --auth-token-env COPILOT_SDK_AUTH_TOKEN --no-auto-login apache-maven-3.9rev-parse ory=/home/REDACTED--show-toplevel launcher.Launcher va/c�� (http block)
    • Triggering command: /home/REDACTED/work/copilot-sdk-java/copilot-sdk-java/target/copilot-sdk/test/harness/node_modules/@github/copilot-linux-x64/copilot /home/REDACTED/work/copilot-sdk-java/copilot-sdk-java/target/copilot-sdk/test/harness/node_modules/@github/copilot-linux-x64/copilot --server --no-auto-update --log-level info --stdio --auth-token-env COPILOT_SDK_AUTH_TOKEN --no-auto-login ame e/git sh -c tsx server.ts e/git de/node/bin/which (http block)

If you need me to access, download, or install something from one of these locations, you can either:


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits February 11, 2026 04:46
Co-authored-by: brunoborges <129743+brunoborges@users.noreply.github.com>
Co-authored-by: brunoborges <129743+brunoborges@users.noreply.github.com>
Copilot AI changed the title [WIP] Improve coverage for ToolInvocation in JaCoCo report Add unit tests for ToolInvocation to achieve 100% coverage Feb 11, 2026
Copilot AI requested a review from brunoborges February 11, 2026 04:49
@brunoborges brunoborges marked this pull request as ready for review February 11, 2026 04:51
Copilot AI and others added 3 commits February 11, 2026 04:57
Co-authored-by: brunoborges <129743+brunoborges@users.noreply.github.com>
…dk-tests-workflow

Fix Spotless formatting violations in ToolInvocationTest
@brunoborges brunoborges merged commit 6ff6f25 into main Feb 11, 2026
3 checks passed
@brunoborges brunoborges deleted the copilot/improve-jacoco-coverage branch February 16, 2026 15:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants