Skip to content

Migrate all Java unit tests from JUnit 4 to JUnit 5 (Jupiter)#984

Open
He-Pin wants to merge 1 commit intomainfrom
removeJunit4
Open

Migrate all Java unit tests from JUnit 4 to JUnit 5 (Jupiter)#984
He-Pin wants to merge 1 commit intomainfrom
removeJunit4

Conversation

@He-Pin
Copy link
Member

@He-Pin He-Pin commented Mar 12, 2026

  • Migrate 94 Java test files across all modules (docs, http-core, http-tests, http-marshallers-java, http2-tests, http-testkit)
  • Add JUnit 5 dependencies (5.9.3) and sbt-jupiter-interface plugin (0.11.0)
  • Create JUnit5RouteTest and ActorSystemExtension for JUnit 5 lifecycle
  • Convert @test(expected=...) to assertThrows()
  • Reorder 3-arg assertion messages (JUnit 4 → JUnit 5 convention)
  • Convert @ignore to @disabled, @Before/@after to @BeforeEach/@AfterEach
  • Delete AllJavaTests.java (JUnit 4 Suite runner, replaced by auto-discovery)
  • Fix pre-existing printStackTrace() in Http2ClientApp.java
  • Preserve JUnitRouteTest and ActorSystemResource for library users (JUnit 4 API)
  • Run scalafmtAll and javafmtAll for formatting compliance

All tests pass: http-testkit(23), http-core(1159), http-tests(1483), marshallers(6), http2(337), docs(509/510 - 1 pre-existing port conflict)

@He-Pin He-Pin marked this pull request as draft March 12, 2026 16:10
- Migrate 94 Java test files across all modules (docs, http-core,
  http-tests, http-marshallers-java, http2-tests, http-testkit)
- Add JUnit 5 dependencies (5.9.3) and sbt-jupiter-interface plugin (0.11.0)
- Create JUnit5RouteTest and ActorSystemExtension for JUnit 5 lifecycle
- Convert @test(expected=...) to assertThrows()
- Reorder 3-arg assertion messages (JUnit 4 → JUnit 5 convention)
- Convert @ignore to @disabled, @Before/@after to @BeforeEach/@AfterEach
- Delete AllJavaTests.java (JUnit 4 Suite runner, replaced by auto-discovery)
- Fix pre-existing printStackTrace() in Http2ClientApp.java
- Preserve JUnitRouteTest and ActorSystemResource for library users (JUnit 4 API)
- Run scalafmtAll and javafmtAll for formatting compliance

All tests pass: http-testkit(23), http-core(1159), http-tests(1483),
marshallers(6), http2(337), docs(509/510 - 1 pre-existing port conflict)

Cross-reviewed by GPT-5.4, Gemini 3 Pro, and Claude Opus 4.6 - all approved.
@He-Pin He-Pin requested a review from pjfanning March 12, 2026 16:36
@He-Pin He-Pin marked this pull request as ready for review March 12, 2026 16:36
testOptions ++= Seq(
Tests.Argument(TestFrameworks.JUnit, "-q", "-v"),
Tests.Argument(TestFrameworks.ScalaTest, "-oDF")),
testFrameworks += new TestFramework("net.aichler.jupiter.api.JupiterFramework"),
Copy link
Contributor

Choose a reason for hiding this comment

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

is this line needed? Doesn't the sbt-jupiter-interface plugin do this already?

addSbtPlugin("com.github.pjfanning" % "sbt-source-dist" % "0.1.13")
addSbtPlugin("com.github.pjfanning" % "sbt-pekko-build" % "0.4.7")
addSbtPlugin("com.lightbend.sbt" % "sbt-java-formatter" % "0.7.0")
addSbtPlugin("net.aichler" % "sbt-jupiter-interface" % "0.11.0")
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

@Philippus Feel free to take it and move further :), otherwise I can update it next weekend maybe.

import org.apache.pekko.http.javadsl.server.Route;
import org.apache.pekko.http.javadsl.testkit.JUnitRouteTest;
import org.junit.Test;
import org.apache.pekko.http.javadsl.testkit.JUnit5RouteTest;
Copy link
Member

Choose a reason for hiding this comment

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

can we add JunitJupiterRouteTest and deprecate JUnit5RouteTest?

Likewise, for any other Pekko classes branded JUnit5.

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.

3 participants