Jérémy CROS
04/13/2022, 3:42 PMclass DummyUseCase {
operator fun invoke(): String = TODO()
}
@Test
fun test() {
val dummyUseCase1: DummyUseCase = mockk()
every { dummyUseCase1.invoke() } returns ""
val dummyUseCase2: DummyUseCase = mockk {
every { this.invoke() } returns ""
}
}
In the second case, I have a compilation error: “Not enough information to infer type variable T”
(I’m fine with the first declaration but we’ve been trying this operator invoke
thing for our use cases that was showcased in one of the recent MAD Skills video and we use sometimes the second mock declaration)
Thanks! 🙂Sam
04/13/2022, 3:50 PMevery { this@mockk.invoke() } returns ""
ephemient
04/13/2022, 3:54 PMthis
ephemient
04/13/2022, 3:54 PMevery { invoke() }
that should work tooJérémy CROS
04/13/2022, 3:55 PMJérémy CROS
04/13/2022, 3:55 PMephemient
04/13/2022, 3:57 PMJérémy CROS
04/13/2022, 3:58 PMSam
04/13/2022, 3:59 PMSam
04/13/2022, 3:59 PMephemient
04/13/2022, 4:00 PMevery
you'll see another receiver there