mdapp
06/05/2019, 5:51 PMrunBlockingTest {
whenever(model.loadData(false)).thenThrow(DeprecatedApiException())
tseisel
06/06/2019, 6:24 AMwhenever(model.loadData(eq(false))).thenThrow(DeprecatedApiException())
When stubbing a function with parameters, you need to wrap expected parameters in eq(...)
, that's a Mockito trick.
Tell me if that solved the problem !mdapp
06/11/2019, 9:01 PMorg.mockito.exceptions.misusing.InvalidUseOfMatchersException:
Invalid use of argument matchers!
2 matchers expected, 1 recorded:
-> at com.nhaarman.mockito_kotlin.MockitoKt.eq(Mockito.kt:114)
This exception may occur if matchers are combined with raw values:
//incorrect:
someMethod(anyObject(), "raw String");
When using matchers, all arguments have to be provided by matchers.
For example:
//correct:
someMethod(anyObject(), eq("String by matcher"));
For more info see javadoc for Matchers class.
tseisel
06/12/2019, 6:18 AMsuspend
functions are translated to a regular function with an additional Continuation
parameter. Older Mockito versions are not aware of that and therefore are unable to properly mock suspending functions. Suspend functions are supported from version 2.23, check if the version you use is 2.23 or newer