You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
io.mockk.MockKException: no answer found for: Server(#1).foo(null, continuation {})
at io.mockk.impl.stub.MockKStub.defaultAnswer(MockKStub.kt:90)
at io.mockk.impl.stub.MockKStub.answer(MockKStub.kt:42)
at io.mockk.impl.recording.states.AnsweringState.call(AnsweringState.kt:16)
at io.mockk.impl.recording.CommonCallRecorder.call(CommonCallRecorder.kt:53)
at io.mockk.impl.stub.MockKStub.handleInvocation(MockKStub.kt:263)
at io.mockk.impl.instantiation.JvmMockFactoryHelper$mockHandler$1.invocation(JvmMockFactoryHelper.kt:25)
at io.mockk.proxy.jvm.advice.Interceptor.call(Interceptor.kt:20)
at io.mockk.proxy.jvm.advice.BaseAdvice.handle(BaseAdvice.kt:42)
at io.mockk.proxy.jvm.advice.jvm.JvmMockKProxyInterceptor.interceptNoSuper(JvmMockKProxyInterceptor.java:45)
at com.app.test.Server$Subclass0.foo(Unknown Source)
at com.app.test.Server$DefaultImpls.foo$default(UnitTests.kt:43)
at com.app.test.UnitTests$foo$1.invokeSuspend(UnitTests.kt:35)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
...
Replacing captureNullable(arg) with any(), or making arg not-null and using capture(arg), both don't produce the error.
Context
MockK version: 1.9.3
Kotlin version: 1.3.50 (coroutines 1.3.1)
JUnit version: 4
Type of test: both in Instrumented test (Android 9) and Unit test (JRE: 1.8.0_202-release-1483-b49-5587405 amd64; JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o; Linux 5.0.0-27-generic).
The text was updated successfully, but these errors were encountered:
Must be similar to the recent #353 . Also, I was trying to work this around by using verify and withNullableArg, but the latter is broken with null values as per #323 .
At the moment it looks like it's impossible to verify null arguments in tests.
oleksiyp
changed the title
Cannot capture nullable argument in mocked suspending methods
Bug: cannot capture nullable argument in mocked suspending methods
Nov 2, 2019
Example code:
Gist with full code
Executing the test produces this exception:
Replacing
captureNullable(arg)
withany()
, or makingarg
not-null and usingcapture(arg)
, both don't produce the error.Context
The text was updated successfully, but these errors were encountered: