I have a scenario like
fun someMethod() {
try {
val response = callApi.method()
val output = processResponse(response)
} catch (throwable: Throwable) {
}
}
Now I'm testing for the scenario when callApi.method() throws an exception and the method processResponse()
is not invoked. It is working as expected but mockk is failing
verify(exactly = 0) { processResponse(any()) }
verify { processResponse(any()) wasNot Called }
with this error:
java.lang.NullPointerException: Parameter specified as non-null is null
My question is that why mockk is trying to execute the processResponse() method with a null response from any() when I'm just verifying that the method is not invoked? Are there any other ways to avoid this error? Thanks