Migrate all Java unit tests from JUnit 4 to JUnit 5 (Jupiter)#984
Open
Migrate all Java unit tests from JUnit 4 to JUnit 5 (Jupiter)#984
Conversation
- 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.
Philippus
reviewed
Mar 22, 2026
| testOptions ++= Seq( | ||
| Tests.Argument(TestFrameworks.JUnit, "-q", "-v"), | ||
| Tests.Argument(TestFrameworks.ScalaTest, "-oDF")), | ||
| testFrameworks += new TestFramework("net.aichler.jupiter.api.JupiterFramework"), |
Contributor
There was a problem hiding this comment.
is this line needed? Doesn't the sbt-jupiter-interface plugin do this already?
Philippus
reviewed
Mar 22, 2026
| 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") |
Contributor
There was a problem hiding this comment.
This is an old version, see https://github.com/sbt/sbt-jupiter-interface?tab=readme-ov-file#usage.
Member
Author
There was a problem hiding this comment.
@Philippus Feel free to take it and move further :), otherwise I can update it next weekend maybe.
pjfanning
reviewed
Mar 22, 2026
| 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; |
Member
There was a problem hiding this comment.
can we add JunitJupiterRouteTest and deprecate JUnit5RouteTest?
Likewise, for any other Pekko classes branded JUnit5.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
All tests pass: http-testkit(23), http-core(1159), http-tests(1483), marshallers(6), http2(337), docs(509/510 - 1 pre-existing port conflict)