Coder Social home page Coder Social logo

Comments (6)

Andersmholmgren avatar Andersmholmgren commented on July 20, 2024 1

+1 for this feature request. Would be super helpful

from mockito.

matanlurey avatar matanlurey commented on July 20, 2024 1

I think we can close this, given the lack of progress, even from myself :)

from mockito.

TedSander avatar TedSander commented on July 20, 2024

Hmm interesting. We may be able to do this because of the matcher interface has describeMismatch which with matchers that conform to the interface should give a pretty good description of the mismatch.

I think the difficulty is going to be in telling which call was the closest. If there are multiple calls on a mock object which do you display? Do you display the mismatch for all of them? That logic seems like it could get evil.

In the case below it isn't clear which value we should show as the miss match. Things get even crazier if you have two arguments that match the signature, but don't match the values. Then you have even more information to display to the user.

No matching calls. All calls: MyService.update(div, {bottom: 5}), MyService.update(div, {top: 6}), MyService.update(div, {bottom: 7})

from mockito.

fibulwinter avatar fibulwinter commented on July 20, 2024

I would prefer to keep verification logic as simple and predictable as possible. So in general I'm again this change.

At the same time I think that we can implement it for just one special case: there is one and only one unmatched call to the mock.

from mockito.

matanlurey avatar matanlurey commented on July 20, 2024

@TedSander: In the case of multiple matching calls, how is normally handled? E.g. if I expected

verify(update(div, bottom: 5))

But the calls are

update(div, bottom: 5);
update(div, bottom: 4);
update(div, bottom: 5);

My verify is valid, right?


@fibulwinter: Verification logic would stay the same... The output message would just be more helpful.

Case in point, I have some method calls with 6-7 parameters. If even one or two is off, it becomes a big hunting game to figure exactly what parameters were unexpected or what parameters were not provided.


I can send a PR with a proof of concept and go from there?

from mockito.

TedSander avatar TedSander commented on July 20, 2024

Correct your verify would pass.

The case I was trying to point out is what if you wanted to verify

verify(update(div, bottom: 4.5))

What would the output be on a miss match? Do you pick one to do the diff on? Do you output the diff for each call?

A PR would be good. We can look at the code and see what we can do.

I agree with @fibulwinter that a single call will be easy enough. Multiple calls might be a lot of noise.

from mockito.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.