I have two configurations for my TestSuite which provide a different beans for injection. This works so long as I set my profile with an annotation.
@ActiveProfiles( profiles={"a"})
and @ActiveProfiles( profiles={"b"})
But I seem unable to set it from the Property Source file
My annotations look like
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = {AConfig.class, BConfig.class })
@PropertySource("classpath:/application.properties")
@TestPropertySource(locations = {"classpath:/application.properties"})
public abstract class AbstractTestIT {
...
}
And the content of application.properties
is
spring.profiles.active="a"
And the results in an unsatisfied dependency
As mentioned setting with @ActiveProfiles
as above works and the correct been is used.
It's almost as if PropertySource and/or TestPropertySource don't work with @RunWith(SpringJUnit4ClassRunner.class)