RFR: 8234876: Unit test classes should not extend Application

Ambarish Rapte arapte at openjdk.java.net
Tue May 26 11:18:37 UTC 2020


Copied from JBS:
As a best practice, unit test classes that are run by Junit should not extend javafx.application.Application.
JUnit constructs an instance of a test class for each test method that it runs. This will be different from the
instance of the object that is constructed when Application.launch method is called, and this can lead to unexpected
behavior. Most of our tests use helper classes or nested (static) sub classes of Application, but the following two
test classes do not:

tests/system/src/test/java/test/com/sun/javafx/image/impl/ImageRaceTest.java
tests/system/src/test/java/test/javafx/scene/control/AccordionTitlePaneLeakTest.java

----
Changes in the tests are:
ImageRaceTest.java->  Does not require a sub class of Application.
AccordionTitlePaneLeakTest.java->  Required minor changes to create a static sub class.

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

Commit messages:
 - 8234876: Unit test classes should not extend Application

Changes: https://git.openjdk.java.net/jfx/pull/237/files
 Webrev: https://webrevs.openjdk.java.net/jfx/237/webrev.00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8234876
  Stats: 51 lines in 2 files changed: 4 ins; 25 del; 22 mod
  Patch: https://git.openjdk.java.net/jfx/pull/237.diff
  Fetch: git fetch https://git.openjdk.java.net/jfx pull/237/head:pull/237

PR: https://git.openjdk.java.net/jfx/pull/237


More information about the openjfx-dev mailing list