I am trying to write junit test cases for my application.After using Junit 5, I am unable to create the necessary beans by using @ContextConfiguration.
It didn't throw any error. But while Autowiring the beans in the testing class I got null values
I have added the following dependencies
testImplementation "org.junit.jupiter:junit-jupiter-api:5.3.0"
testCompile('org.junit.jupiter:junit-jupiter-params:5.3.0')
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:5.3.0"
and my code
@ContextConfiguration(classes = ServiceTestContextConfiguration.class)
public class ApplicationConfigTest {
@Autowired
private ApplicationServiceConfiguration
applicationServiceConfiguration;
@ContextConfiguration
public class ServiceTestContextConfiguration {
@Bean
public ApplicationServiceConfiguration applicationServiceConfiguration() {
return new ApplicationServiceConfiguration();
}
i am using spring-boot 2.