I saw similar post: How to mock method call and return value without running the method?
I am wondering if there is similar method we can use in mockK? something like: doReturn.when(mock).method in mockito
I saw this question before Equivalent of doReturn(x).when(y)... in mockk?
But the answer is: every (method) returns (value)... which is not what I want. Because every(method) will actually run the method
With “every” not executes the original method if you not wish, “every” invalidate the call to original and returns the data declared for will returned.
Example:
every { yourMock.getData() } returns yourData
If you want call original method can use:
every { yourMock.getData() } answers { callOriginal() }
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