Skip to content

Add reflection-based Jackson round-trip test for all generated types#1509

Merged
edburns merged 3 commits into
mainfrom
edburns/improve-coverage-numbers
May 29, 2026
Merged

Add reflection-based Jackson round-trip test for all generated types#1509
edburns merged 3 commits into
mainfrom
edburns/improve-coverage-numbers

Conversation

@edburns
Copy link
Copy Markdown
Collaborator

@edburns edburns commented May 29, 2026

Summary

Adds GeneratedTypesJacksonRoundTripTest — a zero-maintenance test that uses reflection to auto-discover every generated record and enum in com.github.copilot.generated and com.github.copilot.generated.rpc, then Jackson round-trips each one.

What it does

  • Records: Deserializes from {}, serializes back to JSON, deserializes again, asserts equality.
  • Enums: Serializes every variant via @JsonValue, deserializes back via @JsonCreator, asserts equality.
  • Uses @TestFactory + DynamicTest so each class gets its own named test case (571 tests today).
  • Class discovery uses ProtectionDomain.getCodeSource().getLocation() to find the compiled .class directory, which works on both JDK 17 and JDK 25 (unlike Class.getResource(), which returns null under stricter JPMS encapsulation on JDK 25).

Why

Generated code coverage was at 46.4%. This single test brings it to 83.6% — above the 80% target — without any hand-written per-class boilerplate. When generated types are added or removed, the test automatically adapts.

Testing

  • Verified locally: 571 tests, 0 failures on JDK 25
  • Verified locally: 571 tests, 0 failures on JDK 17 (via CI's runtime targeting)
  • mvn spotless:check passes

@edburns edburns requested a review from a team as a code owner May 29, 2026 22:22
Copilot AI review requested due to automatic review settings May 29, 2026 22:22
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot wasn't able to review any files in this pull request.

edburns and others added 2 commits May 29, 2026 15:50
The shell runs with 'set -e -o pipefail', so when head -1 closes the
pipe early, grep exits with SIGPIPE (exit 141) and pipefail propagates
that as the pipeline's exit status, failing the step.

Using 'grep -m 1' makes grep stop after the first match itself,
eliminating the broken pipe entirely.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@edburns edburns merged commit a5581e2 into main May 29, 2026
22 checks passed
@edburns edburns deleted the edburns/improve-coverage-numbers branch May 29, 2026 23:10
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