From f01fc732ac0972a79c1c5b397b23df38ba3a2004 Mon Sep 17 00:00:00 2001 From: Kevin Rushforth Date: Mon, 2 May 2022 13:46:36 +0000 Subject: [PATCH] 8280275: JUnit5 tests using Assumptions API fail to compile in some cases Backport-of: 94807b6edfb9af55be353cab237e8e64007c61dc --- build.gradle | 2 +- modules/javafx.base/src/test/java/test/JUnit5Test.java | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 52a81df55c..72ceb3627f 100644 --- a/build.gradle +++ b/build.gradle @@ -1861,13 +1861,13 @@ allprojects { testImplementation group: "org.hamcrest", name: "hamcrest-core", version: "1.3" testImplementation group: "org.junit.jupiter", name: "junit-jupiter", version: "5.8.1" testImplementation group: "org.junit.jupiter", name: "junit-jupiter-api", version: "5.8.1" + testImplementation group: "org.opentest4j", name: "opentest4j", version: "1.2.0" testRuntimeOnly group: "org.apiguardian", name: "apiguardian-api", version: "1.1.2" testRuntimeOnly group: "org.junit.jupiter", name: "junit-jupiter-engine", version: "5.8.1" testRuntimeOnly group: "org.junit.jupiter", name: "junit-jupiter-params", version: "5.8.1" testRuntimeOnly group: "org.junit.platform", name: "junit-platform-commons", version: "1.8.1" testRuntimeOnly group: "org.junit.platform", name: "junit-platform-engine", version: "1.8.1" testRuntimeOnly group: "org.junit.vintage", name: "junit-vintage-engine", version: "5.8.1" - testRuntimeOnly group: "org.opentest4j", name: "opentest4j", version: "1.2.0" if (BUILD_CLOSED && DO_JCOV) { testImplementation name: "jcov" diff --git a/modules/javafx.base/src/test/java/test/JUnit5Test.java b/modules/javafx.base/src/test/java/test/JUnit5Test.java index e5400d7c66..00a85deb5e 100644 --- a/modules/javafx.base/src/test/java/test/JUnit5Test.java +++ b/modules/javafx.base/src/test/java/test/JUnit5Test.java @@ -26,6 +26,7 @@ package test; import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assumptions.assumeTrue; import org.junit.jupiter.api.Test; @@ -33,7 +34,9 @@ public class JUnit5Test { @Test void junit5ShouldWork() { - System.err.println("JUnit 5 test working!"); + assumeTrue(this != null); + assertNotNull(this); + System.err.println("JUnit 5 test working!"); } }