I'm building an extremly easy Spring Boot application. It has no code, just a simple test :
@RunWith(SpringRunner.class)
@SpringBootTest
public class MyTest {
@Value("${my.key}")
private String key;
@Test
public void test() {
System.out.println(key);
}
}
my.key is defined inside src/main/resources/application.properties (in main/ not test/)
The test doesn't pass because cannot find my.key property (but if I put this property inside src/test/resources/application.properties it works)
I'm sure I have seen plenty of Spring Boot applications where test classes read properties from /main/resources/application.properties
But here it does not work.