Comments (6)
+1 for this feature request. Would be super helpful
from mockito.
I think we can close this, given the lack of progress, even from myself :)
from mockito.
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.
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.
@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.
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)
- Verify constructor HOT 1
- How to test retrofit services with mockito HOT 6
- Question: dockito in dev_dependies? HOT 1
- Error The included part 'mocks.dart' must have a part-of directive. HOT 1
- `verify` failing test but showing in "All calls" HOT 1
- mockito:mockBuilder generator fail using MockSpec custom superclass HOT 5
- How to mock Dio.interceptors.add? HOT 1
- Support for extension-type/inline-class HOT 3
- Why is build_runner is succeeding with 0 outputs? HOT 3
- Support for real executions on Mocking classes HOT 1
- Bad state: Cannot call `when` within a stub response HOT 7
- Cannot create Mock in Dart 3.x: type 'Null' is not a subtype of type 'IOSink' HOT 1
- 'Null' is not a subtype of type 'Future<bool>' HOT 3
- Mocking a class which is created at runtime HOT 1
- Breaking change or typo? HOT 2
- How are we supposed to use any with non null parameters? HOT 2
- Extension type with generic
- Cannot generate mocks for class with method with parameter with default value with a single quote HOT 6
- Dart 3.4.3: invocation_matcher.dart Error: The class 'DeepCollectionEquality' can't be extended outside of its library because it's a final class. HOT 1
- Bad state: Asset URI is missing for abstract class JSObject HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mockito.