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

Usage of isEqual(otherMock) in verify {} causes verification of otherMock.toString() #13

Closed
lupuuss opened this issue Mar 30, 2022 · 1 comment

Comments

@lupuuss
Copy link

lupuuss commented Mar 30, 2022

Whenever isEqual(...) (and similar matchers) is called inside verify {} with mocked argument, it causes argument's toString() method verification.

    val sut = Sut(mock, otherMock)

    @Test
    fun test() {
        sut.process()
        verify { mock.foo(isEqual(otherMock)) } // Assertion error - Expected otherMock.toString() but not called
    }

It seems that isEqual(...) calls otherMock.toString() during ArgConstraint creation and it leads to unintended verification. I think it could be fixed by resolving ArgConstraint.description lazily.

P.S. I am not sure if this use case is fully valid, but I've encountered it inside my side project.

@SalomonBrys
Copy link
Member

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

No branches or pull requests

2 participants