Gauging interest in updating the JavaFX test framework with JUnit 5

John Hendrikx hjohn at xs4all.nl
Fri Sep 24 21:40:26 UTC 2021


Posting this to gauge the interest in adding JUnit 5 as a test 
dependency to JavaFX, enabling writing tests with this new version of 
JUnit while still supporting all JUnit 4 tests.

A draft PR has been submitted here: https://github.com/openjdk/jfx/pull/633

And an issue has been filed here: 
https://bugs.openjdk.java.net/browse/JDK-8274274

Although very personally motivated to be able to write nested unit tests 
in future JavaFX pull requests, I think this would be a great addition 
to have in our testing arsenal.

The main benefits of using JUnit 5:

Better integration with Java 8, specifically use of Lambda functions 
where this would make sense. For example `assertThrows` is really useful 
and can replace the `expected` parameter in the Test annotation 
(although this has also been backported to recent JUnit 4 versions).

Support for better organization of tests (using Nested) and better 
naming.  See this image to see Nested and naming in action: 
https://user-images.githubusercontent.com/995917/111858133-d6ce0f80-8936-11eb-9724-be2c15150590.png

Better extension system allowing to combine extensions whereas JUnit 4 
only allowed one extension at a time.

Native support for parameterized tests, repeated tests, nested tests, 
conditional test execution (by platform or environment for example), 
assumptions, test generation and timeouts.

Please let us know if you'd like to see a newer version of JUnit 
included in JavaFX to further ease testing :)

--John





More information about the openjfx-dev mailing list