Skip to content

Migrate Java tests from JUnit 4 to JUnit 5 Jupiter#35

Open
benfortuna wants to merge 2 commits into
developfrom
migrate-junit4-tests-to-junit5
Open

Migrate Java tests from JUnit 4 to JUnit 5 Jupiter#35
benfortuna wants to merge 2 commits into
developfrom
migrate-junit4-tests-to-junit5

Conversation

@benfortuna
Copy link
Copy Markdown
Member

Summary

The Java test suite was written in JUnit 4 style but the build runs with useJUnitPlatform() and only Jupiter on the test runtime classpath. With no vintage engine registered, JUnit Platform was silently skipping every JUnit 4 test class at discovery time — most of the vCard property and parameter coverage was effectively offline.

This PR completes the full migration to JUnit 5 Jupiter. The vintage engine is added as a temporary bridge, all test sources are migrated, and vintage is then removed.

Key changes

  • 67 test classes rewritten to use only org.junit.jupiter.api.* and org.junit.jupiter.params.*
  • PropertyTest and ParameterTest become abstract @ParameterizedTest hosts; subclasses now supply only public static Stream<Arguments> parameters()
  • New ExtensionPropertyTest and ExtensionParameterTest preserve the base classes' own parameter rows
  • 6 subclasses with their own @Test methods needing extra args (BDay, Member, Revision, Source, Uid, Url) use a dual-@MethodSource pattern
  • Misleading junitVintage version key renamed to junit
  • Pre-existing @Ignore usages converted to @Disabled

Verification

  • ./gradlew clean test → BUILD SUCCESSFUL: 1101 tests, 0 failures, 0 errors, 13 skipped
  • Active test parity: 1091 active tests pre- and post-migration
  • Grep gate: zero org.junit.{Test,Assert,Before,After,Ignore,runner,runners} imports remain
  • Vintage engine removed from testRuntimeClasspath

Notes

  • Test source classes are not published in the main jar, so external impact from the abstract-base reshape is unlikely.
  • Groovy / Spock specs were unaffected (they already ran via spock-core on JUnit Platform).
  • See openspec/changes/migrate-junit4-tests-to-junit5/ for the full proposal, design, and per-phase task breakdown.

Test plan

  • CI green on this branch
  • Verify reports under build/test-results/test/ include every JUnit 4 class that was previously missing (spot check AgentTest, PropertyTest subclasses)
  • Confirm no JUnit 4 imports remain: grep -rE "org\.junit\.(Test|Assert|Before|After|Ignore|runner|runners)\b" src/test/java

🤖 Generated with Claude Code

benfortuna and others added 2 commits May 25, 2026 00:59
The Java test suite was written in JUnit 4 style but the build runs with
useJUnitPlatform() and only Jupiter on the test runtime classpath. With
no vintage engine registered, JUnit Platform was silently skipping every
JUnit 4 test class at discovery time, hiding most of the vCard property
and parameter coverage.

- Rewrite 67 test classes to use only org.junit.jupiter.api and
  org.junit.jupiter.params APIs
- Reshape the PropertyTest / ParameterTest parameterized base classes
  as abstract @ParameterizedTest hosts; subclasses now supply only a
  static Stream<Arguments> parameters() method
- Preserve the base classes' own parameter rows in new concrete
  subclasses ExtensionPropertyTest and ExtensionParameterTest
- Use a dual-@MethodSource pattern for the six subclasses that add
  their own @test method needing extra args (BDay, Member, Revision,
  Source, Uid, Url)
- Rename the misleading junitVintage version key to junit in the
  version catalog
- Convert pre-existing @ignore usages to @disabled

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Move the completed OpenSpec change to openspec/changes/archive/. The
test-framework capability spec lives on at openspec/specs/test-framework/.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.

1 participant