I\'ve got a web application where I have the typical problem that it requires different configuration files for different environments. Some configuration is placed in the a
Looking at Biju's answer I found a working solution.
I created an extra context-file test-context.xml:
Containing the profile:
spring.profiles.active=localtest
And loading the test with:
@RunWith(SpringJUnit4ClassRunner.class)
@TestExecutionListeners({
TestPreperationExecutionListener.class
})
@Transactional
@ActiveProfiles(profiles = "localtest")
@ContextConfiguration(locations = {
"classpath:config/test-context.xml" })
public class TestContext {
@Test
public void testContext(){
}
}
This saves some work when creating multiple test-cases.