RFR: 8369049: [TestBug] Update JUnit to Version 6.0.0

Marius Hanl mhanl at openjdk.org
Thu Oct 2 16:46:05 UTC 2025


On Thu, 2 Oct 2025 16:01:55 GMT, Kevin Rushforth <kcr at openjdk.org> wrote:

> Since you didn't make any changes to the test source code, I presume that JUnit 6 is compatible with 5 (leaving aside the removed deprecations, which don't affect us), unlike the transition from 4 to 5 (version 5 was effectively an entirely new API). 

Yes, it is completely compatible and I could not spot any problems. Locally, everything works and also the GHA work (did a test run before I made the PR).

> I'll take a look at the release notes, but can you summarize the changes you are aware of?

Sure! Most of the changes are either removal of deprecated functions or internal changes / dependency changes which we do not use. 
There is a lot of new functionality for launching test classes / using a custom test engine (we use `junit-jupiter-engine`). 
We don't do any custom stuff, so we are good here. But for reference, here is more information: https://docs.junit.org/current/user-guide/index.html#launcher-api-launcher-cancellation.

One interesting note and addition is: `Stack traces are now pruned up to the test method or lifecycle method`.
The result is that the stack trace is slightly shorter, as it does not contain anything before the test method. 
But for some reason I could not observe that in JavaFX, only another project I did.

> `.\gradlew test`

Before:

...
at org.junit.jupiter.api.AssertionFailureBuilder.build(AssertionFailureBuilder.java:151)
at org.junit.jupiter.api.AssertionFailureBuilder.buildAndThrow(AssertionFailureBuilder.java:132)
at org.junit.jupiter.api.AssertEquals.failNotEqual(AssertEquals.java:197)
at org.junit.jupiter.api.AssertEquals.assertEquals(AssertEquals.java:150)
at org.junit.jupiter.api.AssertEquals.assertEquals(AssertEquals.java:145)
at org.junit.jupiter.api.Assertions.assertEquals(Assertions.java:531)
at de.abc.def.domain.ExportTriggerTest.testExportTriggerPositive(ExportTriggerTest.java:26)
at java.base/java.lang.reflect.Method.invoke(Method.java:565)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1604)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1604)

After:

...
at org.junit.jupiter.api.AssertionFailureBuilder.build(AssertionFailureBuilder.java:158)
at org.junit.jupiter.api.AssertionFailureBuilder.buildAndThrow(AssertionFailureBuilder.java:139)
at org.junit.jupiter.api.AssertEquals.failNotEqual(AssertEquals.java:201)
at org.junit.jupiter.api.AssertEquals.assertEquals(AssertEquals.java:152)
at org.junit.jupiter.api.AssertEquals.assertEquals(AssertEquals.java:147)
at org.junit.jupiter.api.Assertions.assertEquals(Assertions.java:558)
at de.abc.def.domain.ExportTriggerTest.testExportTriggerPositive(ExportTriggerTest.java:26)


> This PR changes gradle build only. What about Eclipse and other IDEs? Are they compatible? Are we going to lose the ability to run junit tests from within the IDE?

Yes they all are compatible, as nothing really changed when writing tests. Imports are the same, the methods are the same, everything is still compatible. I can also verify that it works in IntelliJ.

-------------

PR Comment: https://git.openjdk.org/jfx/pull/1925#issuecomment-3362128624


More information about the openjfx-dev mailing list