mardi 19 novembre 2019

Kotlin with Spring Boot 2.1 WebMvcTest - missing beans

Here's kind of what I have:

@RunWith(SpringRunner::class)
@ActiveProfiles("unit-test")
@WithUserDetails
@WebMvcTest(MyController::class)
class MyControllerTest {

    @MockBean
    lateinit var service: MyService

    @Autowired
    lateinit var mvc: MockMvc

But I keep getting exceptions similar to:

 org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 

and every time I add in a dependency, such as by:

    @MockBean
    lateinit var anotherBean: AnotherBean

another missing bean is thrown (kind of endless).

Is there a proper solution for this in Kotlin?

Aucun commentaire:

Enregistrer un commentaire