using mockk for testing kotlin function.
private val serviceObject = mockk<Service>()
private val serviceToBeTested = ServiceToBeTestd(Service)
fun test(){
when(serviceObject.function1(argument1,argument1))
.thenReturn(<something>)
}
When i try to run it, i get this error:
io.mockk.MockKException: no answer found for: Service(#1).function1(argument1, argument2)
Any idea why ?
ServiceToBeTestd is the service to be tested, Service is wired in it:
open class ServiceToBeTestd
constructor(private val service: Service)
You are using mockito syntax.
Below is correct syntax for mockk.
val car = mockk<Car>()
every { car.drive(Direction.NORTH) } returns Outcome.OK
Please update your syntax.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With