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
Problems with mockito #24
Comments
Hey @creativecreatorormaybenot 👋 Mocktail solves these issues by wrapping the stubs and verifications in a closure which allows the library to execute the stub/verification and handle the TypeError internally. Hope that helps! 👍 |
Thanks a lot for the response @felangel ❤️ Further questions: how does this compare to From your perspective: would you say this is a better approach or just different (emphasis on "your perspective" 🙃)? |
No problem! The main drawback to this approach is that if you want to use an arg matcher (any, captureAny) for a custom type you need to register a fallback value setUpAll(() {
Mocktail.registerFallbackValue<MyType>(MyType());
});
when(() => foo.bar(any<MyType>()).thenReturn(...); I personally think that this approach is still easier, more convenient, and closer to the previous mockito api than the latest mockito release. I’ve opened a proposal to merge mocktail into mockito which you can check out at dart-lang/mockito#347 🙂 |
I see, thanks a lot for that @felangel 🙏 My strawman take on this is that I agree with you 😜 Furthermore, I do not think that arg matchers are worth destroying the syntax anyway 😄 I have not yet experienced cases where I would need them in unit testing. |
Do you want to leave this open as a reference for others @felangel? Otherwise, I would be fine with closing this. Although an in-depth explanation going into the technical details would likely be helpful in general. I suppose one could also transform this into a documentation request :P |
Yeah let’s keep it open until we document the approach better 👍 |
Thanks for sharing this information and your views! Maybe pin this issue :) |
Hi :)
As
mocktail
looks like a promising alternative tomockito
that still provides a nice API, I was wondering howmocktail
solves the problems that mademockito
turn ugly :)I checked the repo and could not find this documented anywhere. So essentially: how does
mocktail
solve the problems described at https://github.com/dart-lang/mockito/blob/9f107e6805f1778cc611f369a8b3338ebf120639/NULL_SAFETY_README.md#problems-with-typical-mocking-and-stubbing?The text was updated successfully, but these errors were encountered: