savrov
11/20/2020, 11:40 PMmockk()
and any()
. Why when i have smth like
coEvery { foo(any()) } returns SomeObject
it works. But when i replace any()
with mockk()
, its print out:
exception=io.mockk.MockKException: no answer found for: SomeClass(#9).foo$domain(ParamType(#5), continuation {})))
bbaldino
11/20/2020, 11:58 PMmockk()
is to create a mock, whereas any()
is a matcher that will match any argument. You'd want to use any()
in that situation if you want to return some result regardless of what the argument passed to foo
was.thanksforallthefish
11/23/2020, 8:14 AMeq
matcher when you don’t specify one, so foo(mockk())
is equivalent to foo(eq(mockk()))
. as brian said, mockk()
creates a strict-by-default mock, meaning every method call on the created mock needs to be known.
anyway, you want to use any()
in your case