Added JRE exclusion

This commit is contained in:
Ashley Frieze 2023-09-27 20:08:05 +01:00
parent ece337978c
commit b8bf616f3e
4 changed files with 6 additions and 6 deletions

View File

@ -169,7 +169,7 @@
<jacoco.version>0.8.6</jacoco.version> <jacoco.version>0.8.6</jacoco.version>
<system-rules.version>1.19.0</system-rules.version> <system-rules.version>1.19.0</system-rules.version>
<system-lambda.version>1.0.0</system-lambda.version> <system-lambda.version>1.0.0</system-lambda.version>
<system-stubs.version>2.1.2</system-stubs.version> <system-stubs.version>2.1.3</system-stubs.version>
<testng.version>7.8.0</testng.version> <testng.version>7.8.0</testng.version>
<assertj.version>3.24.2</assertj.version> <assertj.version>3.24.2</assertj.version>
<junit.pioneer.version>2.1.0</junit.pioneer.version> <junit.pioneer.version>2.1.0</junit.pioneer.version>

View File

@ -32,7 +32,6 @@ class EnvironmentVariablesByAbstractionUnitTest {
fakeEnv.put("OS", "MacDowsNix"); fakeEnv.put("OS", "MacDowsNix");
ReadsEnvironment reader = new ReadsEnvironment(fakeEnv::get); ReadsEnvironment reader = new ReadsEnvironment(fakeEnv::get);
assertThat(reader.whatOs()) assertThat(reader.whatOs()).isEqualTo("MacDowsNix");
.isEqualTo("MacDowsNix");
} }
} }

View File

@ -2,12 +2,14 @@ package com.baeldung.environmentvariablesfortest;
import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledForJreRange;
import org.junit.jupiter.api.condition.JRE;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.util.Map; import java.util.Map;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
// This test can only work well in Java 15 and below @EnabledForJreRange(min = JRE.JAVA_8, max = JRE.JAVA_16)
class EnvironmentVariablesSetDirectlyUnitTest { class EnvironmentVariablesSetDirectlyUnitTest {
@BeforeAll @BeforeAll
static void beforeAll() throws Exception { static void beforeAll() throws Exception {

View File

@ -20,8 +20,7 @@ public class EnvironmentVariablesSystemStubsTestNGUnitTest {
@Test @Test
public void givenEnvironmentVariableWasSet_thenItCanBeRead() { public void givenEnvironmentVariableWasSet_thenItCanBeRead() {
assertThat(System.getenv("testng")) assertThat(System.getenv("testng")).isEqualTo("has environment variables");
.isEqualTo("has environment variables");
} }
} }