[AMORO-3974][common] Migrate self-contained tests from JUnit 4 to JUnit 5#4199
[AMORO-3974][common] Migrate self-contained tests from JUnit 4 to JUnit 5#4199lintingbin wants to merge 1 commit intoapache:masterfrom
Conversation
…it 5 Migrate the JUnit 4 test classes in amoro-common that have no external JUnit 4 consumers to JUnit 5 (org.junit.jupiter): - TestLocalExecutionEngine - TestSimpleFuture - JacksonUtilTest - MemorySizeTest - TestPoolConfig - MockZookeeperServer Shared test base classes and rule helpers (TestAms, TestHMS, AmoroCatalogTestBase, TestAmoroCatalogBase, TestServerTableDescriptor, AmoroRunListener) are kept on JUnit 4 because they are still extended or referenced as @Rule/@ClassRule by JUnit 4 tests in other modules (amoro-ams, amoro-format-iceberg, amoro-format-paimon, amoro-format-mixed-flink, etc.). They will be migrated together with those consumers in a follow-up so the JUnit 4 dependency can be dropped.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #4199 +/- ##
============================================
- Coverage 29.88% 29.88% -0.01%
+ Complexity 4288 4287 -1
============================================
Files 679 679
Lines 55060 55066 +6
Branches 7032 7033 +1
============================================
- Hits 16455 16454 -1
- Misses 37375 37383 +8
+ Partials 1230 1229 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@czy006 @xxubai — would appreciate a review when you have a chance. Why this PR is intentionally narrowThis is a partial migration of
The root issue both PRs hit is that the shared bases in What this PR doesMigrates only the 6 self-contained test classes in
Mechanical changes only: Shared bases / Follow-up plan to fully remove JUnit 4Across the repo there are ~246 JUnit-4 test files left, including 89
Each step keeps CI green because the helpers stay on JUnit 4 until the very last consumer is gone. Happy to keep driving the chain if maintainers are OK with this approach — let me know if you'd prefer a different ordering, or if combining some steps would be easier to review. |
What is this PR for?
Closes part of #3974.
Replaces JUnit 4 (
org.junit.*) imports with JUnit 5 (org.junit.jupiter.api.*) in the self-contained unit tests of theamoro-commonmodule:TestLocalExecutionEngineTestSimpleFutureJacksonUtilTestMemorySizeTestTestPoolConfigMockZookeeperServer@Test(expected=...)is replaced byAssertions.assertThrows(...).@Before/@Afterbecome@BeforeEach/@AfterEach. JUnit 4'sAssert.assertX("msg", expected, actual)is rewritten as JUnit 5'sAssertions.assertX(expected, actual, "msg").MemorySizeTestpreviously used HamcrestassertThat(x, is(y))(pulled in transitively by JUnit 4); those checks are rewritten withAssertions.assertEquals.What is the limitation?
This PR is intentionally scoped: shared test bases and rule helpers in
amoro-commonare not migrated, because they are still extended (or referenced as@Rule/@ClassRule) by JUnit 4 tests in other modules. Migrating them in isolation would break those modules. The remaining files are:TestAms(extendsorg.junit.rules.ExternalResource) — used as@Rule/@ClassRuleinamoro-ams,amoro-format-iceberg,amoro-format-mixed,amoro-format-paimon,amoro-optimizer-common,amoro-openapi-sdk.TestHMS(extendsExternalResource, owns a JUnit 4TemporaryFolder) — same situation.AmoroCatalogTestBaseandTestAmoroCatalogBase— abstract bases extended byTestIcebergAmoroCatalog,TestMixedIcebergFormatCatalog,TestPaimonAmoroCatalog, etc. that use@RunWith(Parameterized.class).TestServerTableDescriptor— abstract base extended byTestIcebergServerTableDescriptorandTestPaimonServerTableDescriptor, both using@RunWith(Parameterized.class).AmoroRunListener(extendsorg.junit.runner.notification.RunListener) — wired into the surefire<properties>ofamoro-mixed-flink-commonas a JUnit 4 listener.These will be migrated together with their consumers in a follow-up so the
junit:junitdependency can be dropped from the parent POM.Type of change
How was this patch tested?
./mvnw -pl amoro-common test— all 96 tests pass under the JUnit Platform provider.