/
NikolayIvkin
/
tutorials1
Обзор
Документация
Войти
/
NikolayIvkin
/
tutorials1
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
testing-modules/testing-libraries-2/src/test/java/com/baeldung/systemrules/ProvidesSystemPropertyUnitTest.java
26 строк
867 B
Jonathan Cook
BAEL-4437 - System Rules (#10047)
18 сен 2020, 00:22
18 сен 2020, 00:22
f6adcd0
Код
Авторство
О чём код?
package com.baeldung.systemrules; import static com.github.stefanbirkner.systemlambda.SystemLambda.restoreSystemProperties; import static org.junit.Assert.assertEquals; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; class ProvidesSystemPropertyUnitTest { @BeforeAll static void setUpBeforeClass() throws Exception { System.setProperty("log_dir", "/tmp/baeldung/logs"); } @Test void givenSetSystemProperty_whenGetLogDir_thenLogDirIsProvidedSuccessfully() throws Exception { restoreSystemProperties(() -> { System.setProperty("log_dir", "test/resources"); assertEquals("log_dir should be provided", "test/resources", System.getProperty("log_dir")); }); assertEquals("log_dir should be provided", "/tmp/baeldung/logs", System.getProperty("log_dir")); } }