Hi guys! I'm struggling with testing Controllers ...
# spring
a
Hi guys! I'm struggling with testing Controllers based on WebFlux. I'm getting an error:
No qualifying bean of type 'kotlin.coroutines.CoroutineContext' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
My controller looks like:
Copy code
@Controller
class MobileController {

  @PostMapping("/register")
  suspend fun register() {
    ...
  }
}
and my test:
Copy code
@WebFluxTest(MobileController::class)
internal class MobileControllerTest {

    @Autowired
    lateinit var client: WebTestClient

    @Test
    fun handleRegister() = kotlinx.coroutines.runBlocking {
        <http://client.post|client.post>()
                .uri("/register")
                .exchange()
                .expectStatus().isOk
    }
}
Does anyone know how to fix it? Thanks in advance 🙂
g
The message implies at some pint you're looking to inject a CoroutineContext. Is there anywhere you're Autowiring or using constructor params and injecting in of type CoroutineContext? Perhaps implicitly within where you provide WebTestClient? That would be weird but that's the only thing I can see you injecting.