I'm trying to test a method with @SpringBootTest and @ActiveProfile("test") in my class. When I run the new tests, everything works fine and the properties are loaded from the test YML file correctly. But when I run all tests, those same tests load the properties from the production YML file.
I've tried using @DirtiesContext, with BEFORE_CLASS and BEFORE_EACH_METHOD flags, on the new test class but it doesn't seem to help.
I have something similar to the following:
@ActiveProfiles("test")
@SpringBootTest
public class NewTestClass{
...
@Test
public void testThatLoadsPropertiesAndShouldLoadApplicationTestYmlFile() {
...
}
}
What am I missing here? is there a simple way of solving this problem?
UPDATE
I disabled the other Integration Tests on the project using @Disable from Junit 5 and checked if the problem persisted. surprisingly, it did. So I'm suspecting it is not an ApplicationContext
caching problem.