RFR: 8339170: ☂ Convert tests to JUnit 5

Marius Hanl mhanl at openjdk.org
Fri Apr 11 21:39:31 UTC 2025


On Fri, 11 Apr 2025 21:11:57 GMT, Andy Goryachev <angorya at openjdk.org> wrote:

>> These are the remaining bits and pieces in order to completely remove the JUnit Vintage Engine, and therefore JUnit 4 from JavaFX.
>> After that, we should either document, that JUnit5 is used (just as information) or close [JDK-8296284](https://bugs.openjdk.org/browse/JDK-8296284) (Since you can not use JUnit4 anymore).
>> 
>> This also removes the `org.hamcrest` dependency, which is actually only used in one test where it can easily be replaced by a `Predicate` (instead of `Matcher`). I'm not convinced that we should keep that dependency for just one test.
>> 
>> Note: I could not get the `:swt` tests to compile/test, in order to run the tests. 
>> I need some guidance here how to instruct `Gradle` to compile this module (and if I need anything else? like swt?).
>> 
>> Also, this probably needs an extra ticket in the JBS?
>
> modules/javafx.swt/src/test/java/test/javafx/embed/swt/SWTCursorsTest.java line 44:
> 
>> 42: 
>> 43:     @Rule
>> 44:     public SwtRule ctx = new SwtRule();
> 
> this looks like a breaking change - what would be the junit5 equivalent of `@Rule`?

`@ExtendWith`, but I think there is no equivalent of a method rule. In any case, another SWT test seems to be just fine without it, so I adapted the pattern to all other tests. We need to check if that works though.

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

PR Review Comment: https://git.openjdk.org/jfx/pull/1774#discussion_r2040323973


More information about the openjfx-dev mailing list