https://kotlinlang.org logo
#mockk
Title
j

Jilles Soeters

07/28/2021, 5:00 PM
So the question is, how do I get
mock.fn()
to return 3
m

Mattia Tommasone

07/29/2021, 7:33 AM
maybe i’m just missing a detail here, but i think you can just do
every { mock.fn() } returns 3
j

Jilles Soeters

07/29/2021, 5:15 PM
Right but I want to test
fn()
and not mock it
m

Mattia Tommasone

07/29/2021, 9:12 PM
oh i see, then you should use `every { mock.fn() } answers { callOriginal() }
j

Jilles Soeters

07/29/2021, 9:13 PM
Oh I haven’t seen that one before, let me try it!
Unfortunately that still gives me
java.lang.NullPointerException
Because a and b are not defined within
fn()
Ahhh because I had
spyk
!
It actually works with
mockk
👍 1
6 Views