Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8234876

Unit test classes should not extend Application

    Details

      Description

      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. See the code review for JDK-8193445 for a case where this caused a problem.

      Most of our tests use helper classes or nested (static) classes as subclasses 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

      This isn't causing any problems today, but we should consider fixing them to follow best practices.

        Attachments

          Activity

            People

            • Assignee:
              arapte Ambarish Rapte
              Reporter:
              kcr Kevin Rushforth
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: