-
-
Notifications
You must be signed in to change notification settings - Fork 231
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
meck:validate/1 always returns true #93
Comments
According to the I would recommend you to use |
OK. I get it. But I think the names and the documentation is confusing. When I use meck:expect I expect something and I also expect meck:validate to validate that the mocked module(s) has been used according to my expectations. But obviously the expectations of meck and my expectations are different, then why is meck:expect called "expect" why not "stub" or "when"? Still, thank you for the quick response and clarifications. |
I started contributing to this project just recently, and I do not know the original author's intention. It is hard to guess since on the one hand the name of the main function is My personal desire is to move Meck API and feature set more towards the record-verify model of use (like Mockito in Java). And all I do is driven by this purpose. But that is just my opinion and Adam (@eproxus) - the project author - might not side with me. But if majority of Meck user base supports this motion then it will probably happen, and I am going to write a Wiki page that explains how to use Meck in record-verify style but for that I need a couple of more features to make it at least in to the develop branch. |
Well, breaking the API just to fix a couple of bad names sounds like too much to me. Mockito is a pretty good framework but currently using meck one can do almost everything that can be done using Mockito. What I want to see is more erlang specific features not just a clone of Mochito. I would like to see more features that allow to mock interaction between processes more easily. For example:
|
The name I've often though about added helpers for processes, but the conclusion has always been that Meck wouldn't be able to provide some significant improvement over Erlang itself in this regard. Consider: Pid = self(),
... do something with Pid
receive Message_pattern -> true; _ -> false end %true if Pid received a message that matches the Message_pattern The gain is not so big. If some more structure is needed one can easily add a small helper function in ones tests. Generalizing this one often just ends up with abstractions over Erlang's own pattern ( That said, I'm happy to get any suggestions on how this could be done, of course. |
While helpers for this simple case would be an unnecessary abstraction, some helpers could be useful, eg when |
To reproduce:
validate returns true but the expected value is false because the bark function hasn't been called yet.
The text was updated successfully, but these errors were encountered: