Skip to content

refactor: migrate JUnit 4 to JUnit 6.1.0#1728

Merged
He-Pin merged 6 commits into
apache:mainfrom
He-Pin:feature/junit6-migration
Jun 27, 2026
Merged

refactor: migrate JUnit 4 to JUnit 6.1.0#1728
He-Pin merged 6 commits into
apache:mainfrom
He-Pin:feature/junit6-migration

Conversation

@He-Pin

@He-Pin He-Pin commented Jun 26, 2026

Copy link
Copy Markdown
Member

Motivation

JUnit 4 is end-of-life. JUnit 6 unifies version numbering across Platform, Jupiter, and Vintage components.

Modification

  • Add JupiterKeys overrides for JUnit Jupiter and Platform 6.1.0
  • Migrate ~98 test files from JUnit 4 annotations to Jupiter equivalents
  • Create LogCapturingExtension for JUnit Jupiter
  • Deprecate LogCapturingJunit4 (use LogCapturingExtension for JUnit Jupiter instead)
  • Keep JUnit 4 dependency for deprecated testkit class (binary compatibility)

Result

All tests run on JUnit 6.1.0. Deprecated JUnit 4 testkit class remains for backward compatibility.

* </root>
* }}}
*/
@deprecated("Use LogCapturingExtension (JUnit Jupiter) instead", "2.1.0")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
@deprecated("Use LogCapturingExtension (JUnit Jupiter) instead", "2.1.0")
@deprecated("Use LogCapturingExtension (JUnit Jupiter) instead", "2.0.0")

@He-Pin He-Pin force-pushed the feature/junit6-migration branch from 29c6a31 to 135c20f Compare June 26, 2026 15:33
@pjfanning

Copy link
Copy Markdown
Member

javafmt busted again

@He-Pin He-Pin force-pushed the feature/junit6-migration branch from 135c20f to a799164 Compare June 26, 2026 16:29
@pjfanning

Copy link
Copy Markdown
Member

docs.scaladsl.CassandraSourceSpec has failed twice - could be flay or this PR might have made things worse

He-Pin added 4 commits June 27, 2026 10:41
Motivation:
JUnit 4 is end-of-life. JUnit 6 unifies version numbering across
Platform, Jupiter, and Vintage components.

Modification:
- Add JupiterKeys overrides for JUnit Jupiter and Platform 6.1.0
- Migrate ~98 test files from JUnit 4 to Jupiter
- Create LogCapturingExtension for JUnit Jupiter
- Deprecate LogCapturingJunit4 (use LogCapturingExtension instead)
- Keep JUnit 4 dependency for deprecated testkit class

Result:
All tests run on JUnit 6.1.0. Deprecated LogCapturingJunit4 remains
available for backward compatibility.
Motivation:
CassandraSourceSpec was aborting in CI with a 4-second timeout waiting
for keyspace creation. The Docker container startup can exceed 4 seconds
on CI runners, causing the entire suite to abort before any test runs.

Modification:
Use an explicit 15-second patience timeout in beforeAll to match the
keyspace statement timeout and the afterAll drop-keyspace timeout.

Result:
CassandraSourceSpec is less likely to abort due to slow Docker startup.

Tests:
Not run - infrastructure timing fix

References:
Refs apache#1728
…ning

Motivation:
sbt warns that ThisBuild / JupiterKeys.junitPlatformVersion is not used
by any settings or tasks, adding noise to build output.

Modification:
Remove the unused override. Only junitJupiterVersion is needed to set
the JUnit Jupiter dependency version to 6.1.0.

Result:
Clean sbt build output without lintUnused warnings.

Tests:
sbt headerCheckAll - passed

References:
Refs apache#1728
Motivation:
Rebase onto main lost the elasticsearch parameterized test conversion
commit. AmqpFlowTest had a coverage regression with a non-parameterized
test. Three files still used JUnit 3 era assertion imports.

Modification:
- Restore ElasticsearchParameterizedTest and OpensearchParameterizedTest
  with correct @ParameterizedTest + @MethodSource from fork branch
- Convert AmqpFlowTest.shouldEmitConfirmationForPublishedMessagesInSimpleFlow
  from @test to @ParameterizedTest @valuesource for full coverage
- Replace junit.framework.TestCase imports with org.junit.jupiter.api.Assertions
  in JmsConnectorsTest (jakartams, jms) and AvroParquetSinkTest

Result:
All parameterized tests correctly use JUnit Jupiter patterns.
No remaining JUnit 3 imports in the codebase.

Tests:
Not run locally - requires Docker for integration tests

References:
Refs apache#1728
@He-Pin He-Pin force-pushed the feature/junit6-migration branch from db775af to de1943a Compare June 27, 2026 05:11
He-Pin added 2 commits June 27, 2026 13:19
…iscovery

Motivation:
All connector tests fail with "Found at least one JUnit 5 test silently
ignored by SBT due to jupiter-interface not being on this projects
test-classpath". The sbt-jupiter-interface plugin requires jupiter-interface
on the test classpath to detect and run JUnit Jupiter tests.

Modification:
Add com.github.sbt.junit:jupiter-interface to the testkit module's
dependencies so it is transitively available on all connector test
classpaths via the existing .dependsOn(testkit % Test) wiring.

Result:
JUnit Jupiter tests are correctly discovered and executed across all
connector modules.

Tests:
Not run - requires CI with Docker for full test suite

References:
Fixes apache#1728
Motivation:
- elasticsearch tests fail to compile: cannot find symbol ParameterizedTest,
  MethodSource, Arguments (from junit-jupiter-params)
- jakartams/jms tests fail to compile: assertTrue(String, boolean) is not
  valid for JUnit Jupiter which uses assertTrue(boolean, String)

Modification:
- Add junit-jupiter-params to testkit dependencies for transitive
  @ParameterizedTest/@MethodSource/@valuesource support
- Swap assertTrue parameter order in JmsConnectorsTest (jms, jakartams)
  from JUnit 3 style (message, condition) to JUnit Jupiter style
  (condition, message)

Result:
All modules compile correctly with JUnit Jupiter assertions.

Tests:
Not run locally - requires CI

References:
Fixes apache#1728
@He-Pin He-Pin requested a review from pjfanning June 27, 2026 07:57
@He-Pin

He-Pin commented Jun 27, 2026

Copy link
Copy Markdown
Member Author

It's now passed

@pjfanning pjfanning left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm

@He-Pin He-Pin merged commit e45dc4d into apache:main Jun 27, 2026
53 checks passed
@He-Pin He-Pin deleted the feature/junit6-migration branch June 27, 2026 10:07
@He-Pin

He-Pin commented Jun 27, 2026

Copy link
Copy Markdown
Member Author

Thanks

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