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

Add support for type arguments matching #66

Closed
renancaraujo opened this issue Aug 5, 2021 · 4 comments
Closed

Add support for type arguments matching #66

renancaraujo opened this issue Aug 5, 2021 · 4 comments
Assignees
Labels
enhancement New feature or request

Comments

@renancaraujo
Copy link
Collaborator

Is your feature request related to a problem? Please describe.

On a scenario where we have a mocked instance with methods that receive type arguments, proceedings like verify never take notice of type arguments,

// real calls
stub.someMethodWithTypeArgs<SomeType>()
stub.someMethodWithTypeArgs<SomeAnotherType>()

// verify call
final result = verify(() => stub.someMethodWithTypeArgs<SomeType>());

print(result.callCount); // will be 2, even though we are verifying inly for calls passing `SomeType`. 

Describe the solution you'd like
Take type arguments into consideration as much as positional and named arguments.

Describe alternatives you've considered
We could evolve to have Type Matchers like Any but probably not for the current state of the support of type arguments on dart.

verify(() => stub.someMethodWithTypeArgs<Any>());

Additional context
The fix would be probably be added here.

@felangel felangel added the enhancement New feature or request label Aug 5, 2021
@felangel felangel self-assigned this Aug 5, 2021
@renancaraujo
Copy link
Collaborator Author

Added a PR for this: #67

@felangel
Copy link
Owner

Related to dart-lang/mockito#155

@shilangyu
Copy link

Now that this is in v0.3.0, how can one replicate the "stub all type arguments" behavior that was in v0.2.0?

@felangel
Copy link
Owner

felangel commented May 6, 2022

@shilangyu you'd need to write a stub for each type you want to mock

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants