Skip to content

Add support for JUnit Jupiter

Choose a tag to compare

@sbabcoc sbabcoc released this 01 Sep 06:52
· 12 commits to main since this release

Highlights

This release adds full JUnit Jupiter support to Selenium Foundation, alongside the existing JUnit 4 and TestNG integrations. Test classes built on JUnit Jupiter now get the same feature set already available under the other two frameworks — automatic retry, artifact capture on failure, and target platform filtering — via a new set of Jupiter-native base classes and extensions.

New base classes, under com.nordstrom.automation.selenium.jupiter:

  • JupiterBase / JupiterClassBase — PER_METHOD/PER_CLASS lifecycle support, mirroring JUnitBase/TestNgBase's driver and page-object storage strategies.
  • JupiterPlatformBase / JupiterTargetBase — target platform support, the Jupiter-native equivalent of JUnitPlatformBase/JUnitTargetBase.
  • DriverWatcher — manages the WebDriver session lifecycle around each test invocation, built on Jupiter's InvocationInterceptor API.
  • PageSourceCapture / ScreenshotCapture — on-failure artifact capture, built on Jupiter Foundation's ArtifactCollector.
  • SeleniumRetryExtension — automatic retry with driver-lifecycle handling re-applied on every attempt, extending Jupiter Foundation's RetryExtension.
  • JupiterGridListener — manages local Selenium Grid startup/shutdown for the whole test run, the Jupiter Platform-native equivalent of the JUnit 4 GridWatcher/DriverListener pair.

New dependency: jupiter-foundation 1.0.0 (-j8 for the selenium3 profile, -j17 for selenium4), providing the underlying JUnit Jupiter retry, artifact capture, and resolved-argument capture mechanisms this integration builds on.

New Gradle task: testJupiter, alongside the existing testNG task, so the Jupiter test suite can be run independently (./gradlew testJupiter) or as part of the full test task.

Bug Fixes

  • Fixed a ThreadLocal cleanup gap in the new Jupiter DriverWatcher: setup logic that could throw (driver acquisition, target-platform mismatch skips) previously ran outside the try/finally block responsible for clearing per-invocation state, risking a leaked ExtensionContext reference on a reused pooled thread under PER_CLASS lifecycle.

Known Limitations

  • This is the first release of the Jupiter integration. While the core lifecycle (driver acquisition, artifact capture, retry, target platform filtering) has been exercised against a live browser session, it has not seen the depth of real-world use the JUnit 4 and TestNG integrations have.
  • Most of JupiterModelTest's coverage is intentionally @Disabled, mirroring JUnitModelTest's own scope — the same underlying page-object-model behavior is exercised via the TestNG suite, and running it three times over was adding significant time to the full build without added value.

Upgrading

No breaking changes for existing JUnit 4 or TestNG users — this release is additive. JUnit Jupiter users can begin extending JupiterBase/JupiterClassBase/JupiterTargetBase directly; see the updated README for usage examples.