Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make inOrder inline #248

Merged
merged 1 commit into from
May 10, 2018
Merged

Make inOrder inline #248

merged 1 commit into from
May 10, 2018

Conversation

matejdro
Copy link
Contributor

This code currently does not compile:

private interface SomeSuspendingClass {
    suspend fun doWork()
}

@Test
fun verifySuspendMethod() = runBlocking {
    val testSubject : SomeSuspendingClass = mock()
    val testSubject2 : SomeSuspendingClass = mock()

    //...

    inOrder(testSubject, testSubject2) {
        verify(testSubject).doWork()
        verify(testSubject2).doWork()
    }
}

Even though there is runBlocking wrapper outside, inOrder runs separately from it. Only workaround for current mockito-kotlin is ugly double runBlocking:

private interface SomeSuspendingClass {
    suspend fun doWork()
}

@Test
fun verifySuspendMethod() = runBlocking {
    val testSubject : SomeSuspendingClass = mock()
    val testSubject2 : SomeSuspendingClass = mock()

    //...

    inOrder(testSubject, testSubject2) {
        runBlocking {
            verify(testSubject).doWork()
            verify(testSubject2).doWork()
        }
    }
}

Making inOrder helper function inline fixes this issue.

@nhaarman nhaarman merged commit fb3581b into mockito:2.x May 10, 2018
@nhaarman
Copy link
Collaborator

Thanks! I have included a test case for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants