1

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.

1 Answer 1

1

It was the mockito version, 2.10 and below does not support suspend functions. bumping it to latest(2.12) fixed it.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.