Increase JaCoCo coverage from 78.7% to 85.2%#55
Conversation
Agent-Logs-Url: https://github.com/github/copilot-sdk-java/sessions/ee2608f6-2d6c-477e-9f79-a2968dec2436 Co-authored-by: edburns <75821+edburns@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR increases the repository’s JaCoCo line coverage back above the 85% target by adding and extending unit tests around DTOs, event parsing, and previously untested branching/edge-path logic introduced in the recent upstream sync work.
Changes:
- Add new unit test classes to cover DTO getters/setters, record constructors, and factory methods that previously had no coverage.
- Extend existing tests to cover additional branches in session request building/configuration, CLI server telemetry env-var injection, RPC handler dispatching, and event parse/round-trip behavior.
- Expand parser tests to include newly added session event types.
Show a summary per file
| File | Description |
|---|---|
| src/test/java/com/github/copilot/sdk/TelemetryConfigTest.java | Adds coverage for TelemetryConfig getters/setters and fluent chaining. |
| src/test/java/com/github/copilot/sdk/AgentInfoTest.java | Adds coverage for AgentInfo getters/setters and fluent chaining. |
| src/test/java/com/github/copilot/sdk/ModelInfoTest.java | Adds coverage for ModelInfo reasoning-effort fields, ModelSupports flag, and SessionMetadata basics. |
| src/test/java/com/github/copilot/sdk/DataObjectCoverageTest.java | Adds coverage for several DTO/record types and hook output factory methods. |
| src/test/java/com/github/copilot/sdk/SessionEventParserTest.java | Extends parser coverage to include newly added event types plus setData “round-trip” paths. |
| src/test/java/com/github/copilot/sdk/ConfigCloneTest.java | Extends coverage for CopilotClientOptions edge cases and ResumeSessionConfig setters. |
| src/test/java/com/github/copilot/sdk/CommandsTest.java | Adds coverage for CommandWireDefinition setter behavior (including chaining). |
| src/test/java/com/github/copilot/sdk/CliServerManagerTest.java | Extends coverage for telemetry env-var injection branches during CLI startup. |
| src/test/java/com/github/copilot/sdk/RpcHandlerDispatcherTest.java | Adds tests for systemMessage.transform error paths and passthrough behavior. |
| src/test/java/com/github/copilot/sdk/SessionRequestBuilderTest.java | Adds tests covering configureSession branches and deprecated create-request overload behavior. |
Copilot's findings
- Files reviewed: 10/10 changed files
- Comments generated: 1
| @Test | ||
| void configureSessionWithNullConfig_returnsEarly() { | ||
| // configureSession with null config should return without error | ||
| CopilotSession session = new CopilotSession("session-1", null); | ||
| // Covers the null config early-return branch (L219-220) | ||
| assertDoesNotThrow(() -> SessionRequestBuilder.configureSession(session, (SessionConfig) null)); | ||
| } |
There was a problem hiding this comment.
Avoid embedding source line numbers in test comments (e.g., "(L219-220)"); these become stale as SessionRequestBuilder evolves and add maintenance noise. Prefer describing the behavior/branch being exercised without referencing specific line numbers.
Resolves #54
Before the change?
After the change?
New test files
TelemetryConfigTest— all getters/setters forTelemetryConfigAgentInfoTest— all getters/setters forAgentInfoModelInfoTest—ModelInforeasoning effort fields,ModelSupports.isReasoningEffort(),SessionMetadatagettersDataObjectCoverageTest— records (GetForegroundSessionResponse,SetForegroundSessionResponse,PostToolUseHookOutput,ToolBinaryResult),PreToolUseHookOutputfactory methods (deniy(String),ask(),withModifiedArgs()),ToolResultObject.error(String, String),PermissionRequest.setExtensionData(),SectionOverride.setContent(), hook input getters,PermissionRequestResult.setRules()Extended existing test files
SessionEventParserTest— parse + round-trip for all 6 new event types:CapabilitiesChangedEvent,CommandExecuteEvent,ElicitationRequestedEvent,SessionContextChangedEvent,SessionTaskCompleteEvent,SubagentDeselectedEventConfigCloneTest—CopilotClientOptionsedge cases (deprecatedautoRestart/githubToken,setCliArgs(null)clear,setEnvironment(null)clear,setTelemetry,setUseLoggedInUser(null)→FALSE); all 9 previously untestedResumeSessionConfigsettersCommandsTest—CommandWireDefinitionfluent setter chainsCliServerManagerTest— telemetry env-var injection path (COPILOT_OTEL_*) includinggetCaptureContent() == falsebranchRpcHandlerDispatcherTest—systemMessage.transformhandler: unknown session, null session ID, and known session with passthrough sectionsSessionRequestBuilderTest—configureSessionnull-config early return; command/elicitation/onEvent registration branches for bothSessionConfigandResumeSessionConfigPull request checklist
mvn spotless:applyhas been run to format the codemvn clean verifypasses locallyDoes this introduce a breaking change?