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

Update to ScalaMock 5.1.0 breaks argument matching #420

Open
xfyre opened this issue Nov 13, 2021 · 0 comments
Open

Update to ScalaMock 5.1.0 breaks argument matching #420

xfyre opened this issue Nov 13, 2021 · 0 comments

Comments

@xfyre
Copy link

xfyre commented Nov 13, 2021

If you want to discuss a new feature, please ignore/clear this form.

ScalaMock Version (e.g. 3.5.0)

5.1

Scala Version (e.g. 2.12)

2.12

Runtime (JVM or JS)

JVM

Please describe the expected behavior of the issue

I have a lot of tests where expects or when is called with a stubbed POJO (Hibernate entity class written in Java). All those methods work as expected in the version 4.1.

Please provide a description of what actually happens

After upgrading from 4.1 to 5.1, all tests which have either when or expects with stubbed POJO arguments, are failing with 'unsatisfied expectation' error (as if the method arguments didn't match). I suspected this has something to do with equality tests, but in failing tests debugger never stops in overridden equals method on POJOs.

In theory I can fix that using where predicate, but this will require to rewrite ~ 100 tests - which I would like to avoid.

Reproducible Test Case

This following code will work in 4.1 and fail in 5.1 with "unsatisfied expectation - never called" error on the call to bindAccount.
Note that SystemUser is a Java (not Scala) class (a Hibernate entity).

  "bind device API" should "bind user device" in {
    val payload = new PBindDevice
    payload.token = "token"

    val user = stub[SystemUser]
    (user.getId _).when().returns(1L)

    (authService.getCurrentUser _).expects().returns(user)
    (firebaseService.bindAccount _).expects(user, payload.token).returns()
    (databaseSession.commit _).expects().returns()

    fixture.bindUserDevice(payload)
  }
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