/
NikolayIvkin
/
tutorials1
Обзор
Документация
Войти
/
NikolayIvkin
/
tutorials1
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
testing-modules/spring-testing/src/test/java/com/baeldung/testpropertysource/PropertiesTestPropertySourceIntegrationTest.java
26 строк
1004 B
Oscar Mauricio Forero Carrillo
BAEL-7136: Improve the companion code for the article to include multiple properties in the @PropertySource annotation (#15885)
16 фев 2024, 21:57
Не верифицирован
16 фев 2024, 21:57
a61328e
Код
Авторство
О чём код?
package com.baeldung.testpropertysource; import static org.assertj.core.api.Assertions.assertThat; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.SpringRunner; @RunWith(SpringRunner.class) @ContextConfiguration(classes = ClassUsingProperty.class) @TestPropertySource(locations = "/other-location.properties", properties = "baeldung.testpropertysource.one=other-properties-value") public class PropertiesTestPropertySourceIntegrationTest { @Autowired ClassUsingProperty classUsingProperty; @Test public void givenACustomPropertySource_whenVariableOneRetrieved_thenValueInPropertyAnnotationIsReturned() { String output = classUsingProperty.retrievePropertyOne(); assertThat(output).isEqualTo("other-properties-value"); } }