Ich verwende die folgende Abhängigkeit: < /p>
Code: Select all
org.mockito
mockito-junit-jupiter
2.23.0
test
< /code>
Hier ist mein Beispiel für den Test: < /p>
@ExtendWith(MockitoExtension.class)
public class TestEnvVariable {
@Mock
System system;
@Test
public void shouldExpandPropertyContentToMatchingSysEnv() throws Exception {
when(system.getenv("KEY")).thenReturn("VALUE");
assertEquals("VALUE", "KEY");
}
}