We have an spring-guice application where we are thinking to create an integration test using the Spring Runner but it is not working as expected given the spring runner is not able to find the guice dependencies in the application context.
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'XYZ' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
The bean XYZ is available in the GUICE context.
MAIN CLASS
@SpringBootApplication
class Main {
// it is a spring boot application with guice injections
}
INTEGRATION TEST
@RunWith(SpringRunner::class)
@SpringBootTest(classes = [Main::class])
@TestPropertySource(properties = arrayOf("spring.config.location = classpath:application-integration-test.yml"))
class MainIT {
@Autowired
private val controller: ApplicationContext? = null
@Test
fun verifyCreateForm() {
Assertions.assertEquals("", controller?.id)
}
}
Is there any way we can achieve this?
Solution to allow intergation test with an application that has both spring and guice injected