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

Verify with any ignores exactly #25

a1flecke opened this Issue Feb 14, 2018 · 2 comments


2 participants

a1flecke commented Feb 14, 2018

Specifying exactly=0 on a verify where an any() matcher is used results in a verification failure when a different call does happen on the mock . This should not be an error as the call did specified did not happen

Example from your class.

class MockCls {
        fun op(a: Int) = a + 1
        fun op2(a: Int, b: Int) = a + b

val mock = mockk<MockCls>()

    fun exactlyZeroWithAny() {

        verify(exactly = 0) {
            mock.op2(3, any())

fun doCalls() {
        every { mock.op(0) } throws RuntimeException("test")
        every { mock.op(1) } returnsMany listOf(1, 2, 3)
        every { mock.op2(2, 1) } returns 3

        assertFailsWith(RuntimeException::class) {

        assertEquals(1, mock.op(1))
        assertEquals(2, mock.op(1))
        assertEquals(3, mock.op(1))
        assertEquals(3, mock.op(1))
        assertEquals(3, mock.op2(2, 1))


java.lang.AssertionError: Verification failed: call 1 of 1: MockCls(#387).op2(eq(3), any())). Only one matching call to MockCls(#387)/op2(Int, Int) happened, but arguments are not matching:
[0]: argument: 2, matcher: eq(3), result: -
[1]: argument: 1, matcher: any(), result: +

@oleksiyp oleksiyp added the bug label Feb 15, 2018

oleksiyp added a commit that referenced this issue Feb 15, 2018


This comment has been minimized.


oleksiyp commented Feb 15, 2018

Version 1.7.5 should resolve issue you found. @a1flecke please check and close ticket if everything fine.


This comment has been minimized.

a1flecke commented Feb 16, 2018

@oleksiyp Confirmed. Thanks for the quick turnaround. Closing the ticket

@a1flecke a1flecke closed this Feb 16, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment