i am getting the below when i try to mock and verify on an activity that's calling a suspend function
Error:
Argument(s) are different! Wanted: userManager.getAccountInfo( (onCreate_callsGetAccountInformation$1) kotlinx.coroutines.experimental.CoroutineScope.() -> kotlin.Unit ); -> at com.pharmacy.AccountActivityTests$onCreate_callsGetAccountInformation$1.doResume(AccountActivityTests.kt:117) Actual invocation has different arguments: userManager.getAccountInfo( () kotlinx.coroutines.experimental.CoroutineScope.() -> kotlin.Unit ) -> at com.pharmacy.AccountActivity$loadAccountInfoAsync$1$1.doResume(AccountActivity.kt:199)
Code:
I have my unit test case decorated with runBlocking like this:
@Test
fun onCreate_callsGetAccountInformation() = runBlocking<Unit>
{ whenever(userManager.getAccountInfo()).thenReturn(AccountInformation())
subject = Robolectric.setupActivity(AccountActivity::class.java)
verify(userManager).getAccountInfo()
}
here -> usermanager.getAccountInfo() is a suspend function.