diff --git a/junit-jupiter-api/src/main/java/org/junit/jupiter/api/condition/EnabledIfEnvironmentVariable.java b/junit-jupiter-api/src/main/java/org/junit/jupiter/api/condition/EnabledIfEnvironmentVariable.java index cd4224564091..d1ef87ba2cce 100644 --- a/junit-jupiter-api/src/main/java/org/junit/jupiter/api/condition/EnabledIfEnvironmentVariable.java +++ b/junit-jupiter-api/src/main/java/org/junit/jupiter/api/condition/EnabledIfEnvironmentVariable.java @@ -30,9 +30,8 @@ *
When declared at the class level, the result will apply to all test methods * within that class as well. * - *
If the specified environment variable is undefined, the presence of this - * annotation will have no effect on whether or not the class or method - * is enabled. + *
If the specified environment variable is undefined, the annotated class or + * method will be disabled. * * @since 5.1 * @see DisabledIfEnvironmentVariable diff --git a/junit-jupiter-api/src/main/java/org/junit/jupiter/api/condition/EnabledIfEnvironmentVariableCondition.java b/junit-jupiter-api/src/main/java/org/junit/jupiter/api/condition/EnabledIfEnvironmentVariableCondition.java index ad0f59f82d4c..2619bf218132 100644 --- a/junit-jupiter-api/src/main/java/org/junit/jupiter/api/condition/EnabledIfEnvironmentVariableCondition.java +++ b/junit-jupiter-api/src/main/java/org/junit/jupiter/api/condition/EnabledIfEnvironmentVariableCondition.java @@ -51,14 +51,12 @@ public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext con // Nothing to match against? if (actual == null) { - return enabled(format("Environment variable [%s] does not exist", name)); + return disabled(format("Environment variable [%s] does not exist", name)); } - if (actual.matches(regex)) { return enabled(format("Environment variable [%s] with value [%s] matches regular expression [%s]", name, actual, regex)); } - // else return disabled(format("Environment variable [%s] with value [%s] does not match regular expression [%s]", name, actual, regex)); } diff --git a/junit-jupiter-api/src/main/java/org/junit/jupiter/api/condition/EnabledIfSystemProperty.java b/junit-jupiter-api/src/main/java/org/junit/jupiter/api/condition/EnabledIfSystemProperty.java index 7163bf4acd99..3b1d7c6fa27d 100644 --- a/junit-jupiter-api/src/main/java/org/junit/jupiter/api/condition/EnabledIfSystemProperty.java +++ b/junit-jupiter-api/src/main/java/org/junit/jupiter/api/condition/EnabledIfSystemProperty.java @@ -30,9 +30,8 @@ *
When declared at the class level, the result will apply to all test methods * within that class as well. * - *
If the specified system property is undefined, the presence of this - * annotation will have no effect on whether or not the class or method - * is enabled. + *
If the specified system property is undefined, the annotated class or + * method will be disabled. * * @since 5.1 * @see DisabledIfSystemProperty diff --git a/junit-jupiter-api/src/main/java/org/junit/jupiter/api/condition/EnabledIfSystemPropertyCondition.java b/junit-jupiter-api/src/main/java/org/junit/jupiter/api/condition/EnabledIfSystemPropertyCondition.java index 644fd6699544..c3526646d5fa 100644 --- a/junit-jupiter-api/src/main/java/org/junit/jupiter/api/condition/EnabledIfSystemPropertyCondition.java +++ b/junit-jupiter-api/src/main/java/org/junit/jupiter/api/condition/EnabledIfSystemPropertyCondition.java @@ -51,14 +51,12 @@ public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext con // Nothing to match against? if (actual == null) { - return enabled(format("System property [%s] does not exist", name)); + return disabled(format("System property [%s] does not exist", name)); } - if (actual.matches(regex)) { return enabled( format("System property [%s] with value [%s] matches regular expression [%s]", name, actual, regex)); } - // else return disabled( format("System property [%s] with value [%s] does not match regular expression [%s]", name, actual, regex)); } diff --git a/junit-jupiter-engine/src/test/java/org/junit/jupiter/api/condition/EnabledIfEnvironmentVariableIntegrationTests.java b/junit-jupiter-engine/src/test/java/org/junit/jupiter/api/condition/EnabledIfEnvironmentVariableIntegrationTests.java index d79abb1d388a..6aa2b728d2d8 100644 --- a/junit-jupiter-engine/src/test/java/org/junit/jupiter/api/condition/EnabledIfEnvironmentVariableIntegrationTests.java +++ b/junit-jupiter-engine/src/test/java/org/junit/jupiter/api/condition/EnabledIfEnvironmentVariableIntegrationTests.java @@ -11,7 +11,6 @@ package org.junit.jupiter.api.condition; import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.fail; import org.junit.jupiter.api.Disabled; @@ -52,7 +51,7 @@ void environmentVariableDoesNotMatch() { @Test @EnabledIfEnvironmentVariable(named = BOGUS, matches = "doesn't matter") void environmentVariableDoesNotExist() { - assertNull(System.getenv(BOGUS)); + fail("should be disabled"); } }