My test properties are overriden with those placed in production properties.
At the very beggining I had both named application.yml
but it didn't work, so I have changed like told in this post to application-test.yml
and use profile.
Now it looks like bellow (kotlin):
@SpringBootTest
@ExtendWith(SpringExtension::class)
@ContextConfiguration(classes = [InvalidPropertiesApplication::class])
@ActiveProfiles("test")
@TestPropertySource(locations = ["classpath:application.yml"])
class InvalidPropertiesApplicationTests {
@Test
fun contextLoads(@Autowired users: Users) {
assertEquals("TEST", users.file)
}
}
in src/main/resources/application.yml
I have only set this property
to PRODUCTION
, in src/test/resources/application-test.yml
to TEST
.
And this test fails. Full example can be found at github
Thx in advance.