diff --git a/documentation/src/docs/asciidoc/release-notes/release-notes-5.8.1.adoc b/documentation/src/docs/asciidoc/release-notes/release-notes-5.8.1.adoc index e4d047f44654..7a150b4359b0 100644 --- a/documentation/src/docs/asciidoc/release-notes/release-notes-5.8.1.adoc +++ b/documentation/src/docs/asciidoc/release-notes/release-notes-5.8.1.adoc @@ -39,7 +39,7 @@ GitHub. ==== New Features and Improvements -* ❓ +* `JAVA_18` has been added to the `JRE` enum for use with JRE-based execution conditions. [[release-notes-5.8.1-junit-vintage]] diff --git a/junit-jupiter-api/src/main/java/org/junit/jupiter/api/condition/JRE.java b/junit-jupiter-api/src/main/java/org/junit/jupiter/api/condition/JRE.java index 200a2df181c6..ba5169de9dbd 100644 --- a/junit-jupiter-api/src/main/java/org/junit/jupiter/api/condition/JRE.java +++ b/junit-jupiter-api/src/main/java/org/junit/jupiter/api/condition/JRE.java @@ -114,11 +114,19 @@ public enum JRE { @API(status = STABLE, since = "5.7.1") JAVA_17, + /** + * Java 18. + * + * @since 5.8.1 + */ + @API(status = STABLE, since = "5.8.1") + JAVA_18, + /** * A JRE version other than {@link #JAVA_8}, {@link #JAVA_9}, * {@link #JAVA_10}, {@link #JAVA_11}, {@link #JAVA_12}, * {@link #JAVA_13}, {@link #JAVA_14}, {@link #JAVA_15}, - * {@link #JAVA_16}, or {@link #JAVA_17}. + * {@link #JAVA_16}, {@link #JAVA_17}, or {@link #JAVA_18}. */ OTHER; @@ -166,6 +174,8 @@ private static JRE determineCurrentVersion() { return JAVA_16; case 17: return JAVA_17; + case 18: + return JAVA_18; default: return OTHER; } diff --git a/junit-jupiter-engine/src/test/java/org/junit/jupiter/api/condition/DisabledForJreRangeConditionTests.java b/junit-jupiter-engine/src/test/java/org/junit/jupiter/api/condition/DisabledForJreRangeConditionTests.java index 3cc2162017b0..d8bc38de16ea 100644 --- a/junit-jupiter-engine/src/test/java/org/junit/jupiter/api/condition/DisabledForJreRangeConditionTests.java +++ b/junit-jupiter-engine/src/test/java/org/junit/jupiter/api/condition/DisabledForJreRangeConditionTests.java @@ -19,6 +19,7 @@ import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava15; import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava16; import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava17; +import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava18; import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava8; import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava9; @@ -119,7 +120,7 @@ void javaMin10() { void other() { evaluateCondition(); assertDisabledOnCurrentJreIf(!(onJava8() || onJava9() || onJava10() || onJava11() || onJava12() || onJava13() - || onJava14() || onJava15() || onJava16() || onJava17())); + || onJava14() || onJava15() || onJava16() || onJava17() || onJava18())); } private void assertDisabledOnCurrentJreIf(boolean condition) { diff --git a/junit-jupiter-engine/src/test/java/org/junit/jupiter/api/condition/DisabledForJreRangeIntegrationTests.java b/junit-jupiter-engine/src/test/java/org/junit/jupiter/api/condition/DisabledForJreRangeIntegrationTests.java index da27aa6b4a25..93b8e7d55085 100644 --- a/junit-jupiter-engine/src/test/java/org/junit/jupiter/api/condition/DisabledForJreRangeIntegrationTests.java +++ b/junit-jupiter-engine/src/test/java/org/junit/jupiter/api/condition/DisabledForJreRangeIntegrationTests.java @@ -21,6 +21,7 @@ import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava15; import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava16; import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava17; +import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava18; import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava8; import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava9; import static org.junit.jupiter.api.condition.JRE.JAVA_10; @@ -86,7 +87,7 @@ void javaMin10() { @DisabledForJreRange(min = OTHER, max = OTHER) void other() { assertTrue(onJava8() || onJava9() || onJava10() || onJava11() || onJava12() || onJava13() || onJava14() - || onJava15() || onJava16() || onJava17()); + || onJava15() || onJava16() || onJava17() || onJava18()); } } diff --git a/junit-jupiter-engine/src/test/java/org/junit/jupiter/api/condition/DisabledOnJreConditionTests.java b/junit-jupiter-engine/src/test/java/org/junit/jupiter/api/condition/DisabledOnJreConditionTests.java index c0428d3e80b5..f0f65ab91378 100644 --- a/junit-jupiter-engine/src/test/java/org/junit/jupiter/api/condition/DisabledOnJreConditionTests.java +++ b/junit-jupiter-engine/src/test/java/org/junit/jupiter/api/condition/DisabledOnJreConditionTests.java @@ -20,6 +20,7 @@ import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava15; import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava16; import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava17; +import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava18; import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava8; import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava9; @@ -166,6 +167,15 @@ void java17() { assertDisabledOnCurrentJreIf(onJava17()); } + /** + * @see DisabledOnJreIntegrationTests#java18() + */ + @Test + void java18() { + evaluateCondition(); + assertDisabledOnCurrentJreIf(onJava18()); + } + /** * @see DisabledOnJreIntegrationTests#other() */ @@ -173,7 +183,7 @@ void java17() { void other() { evaluateCondition(); assertDisabledOnCurrentJreIf(!(onJava8() || onJava9() || onJava10() || onJava11() || onJava12() || onJava13() - || onJava14() || onJava15() || onJava16() || onJava17())); + || onJava14() || onJava15() || onJava16() || onJava17() || onJava18())); } private void assertDisabledOnCurrentJreIf(boolean condition) { diff --git a/junit-jupiter-engine/src/test/java/org/junit/jupiter/api/condition/DisabledOnJreIntegrationTests.java b/junit-jupiter-engine/src/test/java/org/junit/jupiter/api/condition/DisabledOnJreIntegrationTests.java index 3cabc869504e..8414b1bc98e0 100644 --- a/junit-jupiter-engine/src/test/java/org/junit/jupiter/api/condition/DisabledOnJreIntegrationTests.java +++ b/junit-jupiter-engine/src/test/java/org/junit/jupiter/api/condition/DisabledOnJreIntegrationTests.java @@ -21,6 +21,7 @@ import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava15; import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava16; import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava17; +import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava18; import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava8; import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava9; import static org.junit.jupiter.api.condition.JRE.JAVA_10; @@ -31,6 +32,7 @@ import static org.junit.jupiter.api.condition.JRE.JAVA_15; import static org.junit.jupiter.api.condition.JRE.JAVA_16; import static org.junit.jupiter.api.condition.JRE.JAVA_17; +import static org.junit.jupiter.api.condition.JRE.JAVA_18; import static org.junit.jupiter.api.condition.JRE.JAVA_8; import static org.junit.jupiter.api.condition.JRE.JAVA_9; import static org.junit.jupiter.api.condition.JRE.OTHER; @@ -58,7 +60,7 @@ void missingJreDeclaration() { @Test @DisabledOnJre(value = { JAVA_8, JAVA_9, JAVA_10, JAVA_11, JAVA_12, JAVA_13, JAVA_14, JAVA_15, JAVA_16, JAVA_17, - OTHER }, disabledReason = "Disabled on every JRE") + JAVA_18, OTHER }, disabledReason = "Disabled on every JRE") void disabledOnAllJavaVersions() { fail("should be disabled"); } @@ -123,11 +125,17 @@ void java17() { assertFalse(onJava17()); } + @Test + @DisabledOnJre(JAVA_18) + void java18() { + assertFalse(onJava18()); + } + @Test @DisabledOnJre(OTHER) void other() { assertTrue(onJava8() || onJava9() || onJava10() || onJava11() || onJava12() || onJava13() || onJava14() - || onJava15() || onJava16() || onJava17()); + || onJava15() || onJava16() || onJava17() || onJava18()); } } diff --git a/junit-jupiter-engine/src/test/java/org/junit/jupiter/api/condition/EnabledForJreRangeConditionTests.java b/junit-jupiter-engine/src/test/java/org/junit/jupiter/api/condition/EnabledForJreRangeConditionTests.java index 7f70a1b3937b..7d908f768c08 100644 --- a/junit-jupiter-engine/src/test/java/org/junit/jupiter/api/condition/EnabledForJreRangeConditionTests.java +++ b/junit-jupiter-engine/src/test/java/org/junit/jupiter/api/condition/EnabledForJreRangeConditionTests.java @@ -19,6 +19,7 @@ import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava15; import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava16; import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava17; +import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava18; import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava8; import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava9; @@ -119,7 +120,7 @@ void javaMin10() { void other() { evaluateCondition(); assertEnabledOnCurrentJreIf(!(onJava8() || onJava9() || onJava10() || onJava11() || onJava12() || onJava13() - || onJava14() || onJava15() || onJava16() || onJava17())); + || onJava14() || onJava15() || onJava16() || onJava17() || onJava18())); } private void assertEnabledOnCurrentJreIf(boolean condition) { diff --git a/junit-jupiter-engine/src/test/java/org/junit/jupiter/api/condition/EnabledForJreRangeIntegrationTests.java b/junit-jupiter-engine/src/test/java/org/junit/jupiter/api/condition/EnabledForJreRangeIntegrationTests.java index 241eadb79aeb..4416a28699cb 100644 --- a/junit-jupiter-engine/src/test/java/org/junit/jupiter/api/condition/EnabledForJreRangeIntegrationTests.java +++ b/junit-jupiter-engine/src/test/java/org/junit/jupiter/api/condition/EnabledForJreRangeIntegrationTests.java @@ -21,6 +21,7 @@ import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava15; import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava16; import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava17; +import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava18; import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava8; import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava9; import static org.junit.jupiter.api.condition.JRE.JAVA_10; @@ -83,7 +84,7 @@ void javaMax12() { @EnabledForJreRange(min = JAVA_10) void javaMin10() { assertTrue(onJava10() || onJava11() || onJava12() || onJava13() || onJava14() || onJava15() || onJava16() - || onJava17()); + || onJava17() || onJava18()); assertFalse(onJava9()); } @@ -91,7 +92,7 @@ void javaMin10() { @EnabledForJreRange(min = OTHER, max = OTHER) void other() { assertFalse(onJava8() || onJava9() || onJava10() || onJava11() || onJava12() || onJava13() || onJava14() - || onJava15() || onJava16() || onJava17()); + || onJava15() || onJava16() || onJava17() || onJava18()); } } diff --git a/junit-jupiter-engine/src/test/java/org/junit/jupiter/api/condition/EnabledOnJreConditionTests.java b/junit-jupiter-engine/src/test/java/org/junit/jupiter/api/condition/EnabledOnJreConditionTests.java index abe24fa05d10..a782b07728a0 100644 --- a/junit-jupiter-engine/src/test/java/org/junit/jupiter/api/condition/EnabledOnJreConditionTests.java +++ b/junit-jupiter-engine/src/test/java/org/junit/jupiter/api/condition/EnabledOnJreConditionTests.java @@ -20,6 +20,7 @@ import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava15; import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava16; import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava17; +import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava18; import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava8; import static org.junit.jupiter.api.condition.EnabledOnJreIntegrationTests.onJava9; @@ -165,6 +166,15 @@ void java17() { assertEnabledOnCurrentJreIf(onJava17()); } + /** + * @see EnabledOnJreIntegrationTests#java18() + */ + @Test + void java18() { + evaluateCondition(); + assertEnabledOnCurrentJreIf(onJava18()); + } + /** * @see EnabledOnJreIntegrationTests#other() */ @@ -172,7 +182,7 @@ void java17() { void other() { evaluateCondition(); assertEnabledOnCurrentJreIf(!(onJava8() || onJava9() || onJava10() || onJava11() || onJava12() || onJava13() - || onJava14() || onJava15() || onJava16() || onJava17())); + || onJava14() || onJava15() || onJava16() || onJava17() || onJava18())); assertCustomDisabledReasonIs("Disabled on almost every JRE"); } diff --git a/junit-jupiter-engine/src/test/java/org/junit/jupiter/api/condition/EnabledOnJreIntegrationTests.java b/junit-jupiter-engine/src/test/java/org/junit/jupiter/api/condition/EnabledOnJreIntegrationTests.java index f170cad98c91..f1a9bbd430c9 100644 --- a/junit-jupiter-engine/src/test/java/org/junit/jupiter/api/condition/EnabledOnJreIntegrationTests.java +++ b/junit-jupiter-engine/src/test/java/org/junit/jupiter/api/condition/EnabledOnJreIntegrationTests.java @@ -20,6 +20,7 @@ import static org.junit.jupiter.api.condition.JRE.JAVA_15; import static org.junit.jupiter.api.condition.JRE.JAVA_16; import static org.junit.jupiter.api.condition.JRE.JAVA_17; +import static org.junit.jupiter.api.condition.JRE.JAVA_18; import static org.junit.jupiter.api.condition.JRE.JAVA_8; import static org.junit.jupiter.api.condition.JRE.JAVA_9; import static org.junit.jupiter.api.condition.JRE.OTHER; @@ -48,7 +49,8 @@ void missingJreDeclaration() { } @Test - @EnabledOnJre({ JAVA_8, JAVA_9, JAVA_10, JAVA_11, JAVA_12, JAVA_13, JAVA_14, JAVA_15, JAVA_16, JAVA_17, OTHER }) + @EnabledOnJre({ JAVA_8, JAVA_9, JAVA_10, JAVA_11, JAVA_12, JAVA_13, JAVA_14, JAVA_15, JAVA_16, JAVA_17, JAVA_18, + OTHER }) void enabledOnAllJavaVersions() { } @@ -112,11 +114,17 @@ void java17() { assertTrue(onJava17()); } + @Test + @EnabledOnJre(JAVA_18) + void java18() { + assertTrue(onJava18()); + } + @Test @EnabledOnJre(value = OTHER, disabledReason = "Disabled on almost every JRE") void other() { assertFalse(onJava8() || onJava9() || onJava10() || onJava11() || onJava12() || onJava13() || onJava14() - || onJava15() || onJava16() || onJava17()); + || onJava15() || onJava16() || onJava17() || onJava18()); } static boolean onJava8() { @@ -159,4 +167,8 @@ static boolean onJava17() { return JAVA_VERSION.startsWith("17"); } + static boolean onJava18() { + return JAVA_VERSION.startsWith("18"); + } + }