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

SwingNodePlatformExitCrashTest fails with JUnit 5.11.3

XMLWordPrintable

    • b22

      The update of JUnit to 5.11.3 in JDK-8345937 uncovered a latent test bug in SwingNodePlatformExitCrashTest. That test now fails with JUnit 5.11.3.


      The following test consistently fails on macOS and Linux (I haven't tried it on Windows) with JUnit 5.11.3 in our CI and on my local macOS system:

      $ gradle -PTEST_ONLY=true -PFULL_TEST=true -PUSE_ROBOT=true :systemTests:test --tests SwingNodePlatformExitCrashTest
      ...
      SwingNodePlatformExitCrashTest > executionError FAILED
          org.opentest4j.AssertionFailedError: Exceeded timeout limit of 10000 msec
              at app//test.util.Util.runAndWait(Util.java:168)
              at app//test.util.Util.runAndWait(Util.java:139)
              at app//test.util.Util.shutdown(Util.java:316)
              at app//test.robot.javafx.embed.swing.SwingNodeBase.teardownOnce(SwingNodeBase.java:81)
              at java.base@23/java.lang.reflect.Method.invoke(Method.java:580)
              at java.base@23/java.util.ArrayList.forEach(ArrayList.java:1597)
              at java.base@23/java.util.Collections$UnmodifiableCollection.forEach(Collections.java:1117)
              at java.base@23/java.util.ArrayList.forEach(ArrayList.java:1597)

      The abstract SwingNodeBase base class calls Util::shutdown from a static tearDownOnce method, annotated with @AfterAll. The SwingNodePlatformExitCrashTest shuts down the FX toolkit as part of the test so must not call shutdown a second time. The current test logic attempts to "override" the static method in the base class with an @AfterAll annotation on a static method of the same name in the subclass. This accidentally works in JUnit 5.8 by hiding the method in the parent class, but no longer does in JUnit 5.11.

      The right fix is for the subclass to set a flag such that the superclass will skip the call to Util::shutdown.

            kcr Kevin Rushforth
            kcr Kevin Rushforth
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: