'Spring Test ActiveProfiles is not reading the properties from the test properties file

I have my custom properties defined in application.properties file located in src/main/resources folder. I want to add test cases for my application hence I added application-integration.properties in the src/test/resources folder as mentioned here. The test case is added as below

@SpringBootTest
@ActiveProfiles("integration")
public class ServiceATest {

    @Value("${app.api.url}")
    private String apiUrl;

    @Test
    public void testService() {
        Assertions.assertNotNull(apiUrl);
    }
}

The above test case fails. I do not understand why the properties are not read from application-integration.properties and nor from application.properties. The latter is not expected though still just for the understanding. Any idea what could be going wrong?

Thanks.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source