I need to read properties for unit testing in one of the test class using Environment bean but spring is failed to create environment bean.
@RunWith(SpringRunner.class)
@TestPropertySource(locations = "/application-test.properties")
public class CardTest {
@Autowired
Environment environment;
@Test
public void givenPropertyFetchesAndValidatesTheValue() {
String output = environment.getProperty("test");
assertThat(output).isEqualTo("502123");
}
}
Error:
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.core.env.Environment]: Specified class is an interface.
Please help