Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8346222: SwingNodePlatformExitCrashTest fails with JUnit 5.11.3 #1664

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kevinrushforth
Copy link
Member

@kevinrushforth kevinrushforth commented Dec 13, 2024

This PR fixes a latent test bug in test bug in SwingNodePlatformExitCrashTest by setting a flag to skip shutdown rather than relying on a quirk of JUnit 5.8.1.

I discovered this while testing PR #1662 which updates JUnit to 5.11.3.

$ gradle sdk shims
$ 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)
        ...

The abstract SwingNodeBase base class calls Util::shutdown from its 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.


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8346222: SwingNodePlatformExitCrashTest fails with JUnit 5.11.3 (Bug - P3)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jfx.git pull/1664/head:pull/1664
$ git checkout pull/1664

Update a local copy of the PR:
$ git checkout pull/1664
$ git pull https://git.openjdk.org/jfx.git pull/1664/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 1664

View PR using the GUI difftool:
$ git pr show -t 1664

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jfx/pull/1664.diff

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Dec 13, 2024

👋 Welcome back kcr! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@kevinrushforth
Copy link
Member Author

@prsadhuk Please review

@Maran23 Can you also take a look at this?

@openjdk
Copy link

openjdk bot commented Dec 13, 2024

❗ This change is not yet ready to be integrated.
See the Progress checklist in the description for automated requirements.

@openjdk openjdk bot added the rfr Ready for review label Dec 13, 2024
@mlbridge
Copy link

mlbridge bot commented Dec 13, 2024

Webrevs

@kevinrushforth
Copy link
Member Author

As an FYI, the behavior change that exposed this latent bug in our test was a deliberate change in JUnit 5.11.

junit-team/junit5#3553

Indeed it was the case that before 5.11, a static method annotated with @BeforeAll or @AfterAll in a subclass would hide the same named method in the superclass, and starting in 5.11, it no longer does.

@Maran23
Copy link
Member

Maran23 commented Dec 14, 2024

Thanks for investigating this in #1662. I have read all comments and can confirm your investigation!
Funny enough, I found a similar problem when updating another project to the latest JUnit version.
So it seems like a good idea to update JUnit so that we can no longer write tests that violate this behavior, only to find out later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rfr Ready for review
Development

Successfully merging this pull request may close these issues.

2 participants