@Value annotation is not working with Infinitest 5.2.0 on STS 3.9.6

211 Views Asked by At

JUnit tests are failing when triggered by Infinitest complaining about wrong configuration values. E.g.

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'databaseConfiguration': Injection of autowired dependencies failed; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'spring.data.mongodb.database' in value "${spring.data.mongodb.database}"

It seems, that application properties are not loaded, although they present in the resources folder and working fine when the tests are running manually.

I am using Spring Tool Suite 3.9.6 with Infinitest 5.2.0

The unit tests are annotated like this

@RunWith(SpringRunner.class)
@SpringBootTest
@ContextConfiguration(classes = ChargeConsumerApplication.class)
@ActiveProfiles("test")
public class ChargeConsumerApplicationTest {

    @Test
    public void contextLoads() {
    }

    @Test
    public void applicationContextLoaded() {
    }

    @Test
    public void applicationContextTest() {
        ChargeConsumerApplication.main(new String[] {});
    }
}

Is it an STS problem or I need some extra configuration for Infinitest itself?

0

There are 0 best solutions below