Ashish Kumar Joy

05/18/2020, 7:24 AM
@LeoColman Thanks I had seen that post. I am looking for a test where dependency of webcontroller has been mocked using mockk and then get handle of that mock in test. Basically a port of follwing micronaut-kotest test in spring-kotest
Copy code
class GreetControllerTest(
        @Inject @Client("/") val httpClient: RxHttpClient,
        val greetService: GreetService
) : StringSpec({
    "should greet" {
        every { getMock(greetingService).greetPerson(name) } returns "Hello World"
        val greeting = httpClient.toBlocking()
                .exchange(GET("/greet"), String::class)
        greeting shouldBe "Hello World"
}) {
    fun mockedGreetingService() = mockk<GreetingService>()

class GreetingController(val greetingService: GreetingService) {
    fun greet(name: String) = greetingService.greetPerson(name)