Skip to content

[KYUUBI #7473] Migrate Java tests from JUnit 4 to JUnit 5#7474

Open
wangzhigang1999 wants to merge 3 commits into
apache:masterfrom
wangzhigang1999:kyuubi-7473-junit5-migration
Open

[KYUUBI #7473] Migrate Java tests from JUnit 4 to JUnit 5#7474
wangzhigang1999 wants to merge 3 commits into
apache:masterfrom
wangzhigang1999:kyuubi-7473-junit5-migration

Conversation

@wangzhigang1999
Copy link
Copy Markdown
Contributor

@wangzhigang1999 wangzhigang1999 commented May 25, 2026

Why are the changes needed?

Closes #7473.

JUnit 4 has been in maintenance mode since 4.13.2 (Feb 2021); modern Java test deps (Mockito 5, Testcontainers, etc.) target JUnit 5. Our usage is shallow (no @Rule / @ClassRule / Theories), so the migration is mostly mechanical.

Migrates all five modules with Java tests: kyuubi-rest-client, kyuubi-util, kyuubi-hive-jdbc, kyuubi-hive-beeline, and externals/kyuubi-data-agent-engine. Drops the direct junit:junit dependency and junit.version property from the root pom; transitive exclusions are kept. junit-jupiter is pinned to the latest stable, 5.14.4.

How was this patch tested?

build/mvn -Pfast test -pl <module> -am on each of the five modules — all green. kyuubi-data-agent-engine has 7 live tests skipped via Assumptions.assumeTrue (require an external LLM API). dev/reformat clean.

Was this patch authored or co-authored using generative AI tooling?

Assisted-by: Claude:claude-opus-4-7

Comment thread pom.xml Outdated
@wangzhigang1999 wangzhigang1999 marked this pull request as ready for review May 25, 2026 13:33
@wangzhigang1999 wangzhigang1999 force-pushed the kyuubi-7473-junit5-migration branch from 70644df to ac9b18c Compare May 26, 2026 03:33
@wangzhigang1999 wangzhigang1999 marked this pull request as draft May 26, 2026 03:46
- Add junit-bom 5.11.4 to root dependencyManagement; keep junit 4.13.2
  for vendored Hive beeline tests under org.apache.hive.beeline.
- Switch kyuubi-rest-client, kyuubi-util, kyuubi-hive-jdbc and
  kyuubi-data-agent-engine to junit-jupiter only.
- Rewrite imports and annotations (@test, @before -> @beforeeach, ...),
  swap message argument from msg-first to msg-last,
  convert @RunWith(Parameterized.class) to @ParameterizedTest with
  @MethodSource / @valuesource, replace @test(expected=...) with
  assertThrows, and convert Assume.assumeTrue to Assumptions.assumeTrue.
- Use static imports throughout per google-java-format (no class-
  qualified Assertions.X calls, no wildcard imports).
- kyuubi-hive-beeline stays on JUnit 4 to avoid diverging from the
  vendored Apache Hive beeline tests.
@wangzhigang1999 wangzhigang1999 force-pushed the kyuubi-7473-junit5-migration branch from ac9b18c to 5fa8033 Compare May 26, 2026 04:59
Replace assertTrue(expr.equals(literal)) with assertEquals(literal, expr)
in tests touched by the JUnit 5 migration, plus one assertTrue(x == 100)
to assertEquals(100, x). Pure cleanup, no behavior change.

Assisted-by: Claude:claude-opus-4-7
@wangzhigang1999 wangzhigang1999 marked this pull request as ready for review May 26, 2026 08:15
@wangzhigang1999
Copy link
Copy Markdown
Contributor Author

Done — kyuubi-hive-beeline migrated, direct junit:junit dep removed, and bumped to 5.14.4. CI all green.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Migrate Java tests from JUnit 4 to JUnit 5

2 participants