JDK-8280275 : JUnit5 tests using Assumptions API fail to compile in some cases
  • Type: Bug
  • Component: javafx
  • Sub-Component: other
  • Affected Version: openjfx18
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2022-01-19
  • Updated: 2022-11-03
  • Resolved: 2022-01-20
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 8 Other
8u341Fixed openjfx11.0.16Fixed
Related Reports
Blocks :  
Relates :  
Relates :  
Description
Tests using the JUnit 5 Assumptions API fails to compile due to missing dependencies. To reproduce, run the following with "gradle test" on the command line:

-----------------------------------------------------------------------------
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assumptions.assumeTrue;

import org.junit.jupiter.api.Test;

public class JUnit5Test {

    @Test
    void junit5ShouldWork() {
        assumeTrue(this != null);

        assertNotNull(this);
        System.err.println("JUnit 5 test working!");
    }
}
-----------------------------------------------------------------------------


It will fail with the following error:

> Task :base:compileTestJava
modules/javafx.base/src/test/java/test/JUnit5Test.java:37: error: cannot access TestAbortedException
        assumeTrue(this != null);
                  ^
  class file for org.opentest4j.TestAbortedException not found

Comments
A pull request was submitted for review. URL: https://git.openjdk.java.net/jfx17u/pull/59 Date: 2022-05-09 21:20:29 +0000
10-05-2022

A pull request was submitted for review. URL: https://git.openjdk.java.net/jfx11u/pull/98 Date: 2022-04-30 13:48:01 +0000
02-05-2022

I plan to backport this to facilitate backports of bugs that use JUnit 5 in their tests.
13-04-2022

Changeset: 94807b6e Author: Kevin Rushforth <kcr@openjdk.org> Date: 2022-01-20 12:12:43 +0000 URL: https://git.openjdk.java.net/jfx/commit/94807b6edfb9af55be353cab237e8e64007c61dc
20-01-2022

A pull request was submitted for review. URL: https://git.openjdk.java.net/jfx/pull/720 Date: 2022-01-19 15:18:48 +0000
19-01-2022

The problem is that the opentest4j library is listed in build.gradle as a runtime-only dependency, when in fact it is a compile-time dependency. The fix is to make the following change: - testRuntimeOnly group: "org.opentest4j", name: "opentest4j", version: "1.2.0" + testImplementation group: "org.opentest4j", name: "opentest4j", version: "1.2.0"
19-01-2022

This was discovered during the review of JDK-8205915. See: https://github.com/openjdk/jfx/pull/715#issuecomment-1016516818
19-01-2022