eproxus / meck

A mocking library for Erlang
http://eproxus.github.io/meck
Apache License 2.0
811 stars 231 forks source link

Feature/honest mocks #75

Closed horkhe closed 11 years ago

horkhe commented 12 years ago

Meck is so powerful that it allows mocking non-existent functions and even non-existent modules. But as every coin it comes with two sides. And the bad thing here is that all sorts of problem caused by refactoring/removing/renaming actions are not detected by meck featured unit tests. Namely:

To have such cases detected at the earliest possibility honest mocks were introduced. They expose the following properties:

I personally think that all mocks created by meck should be honest by default, but I did not want to break the backwards compatibility.

eproxus commented 12 years ago

I also like the idea of using honest by default. My guess is that 95-99 percent of the mocking done with Meck is with preexisting modules. Perhaps (if we make it default) another option could be added to make them "non-honest"? Like meck:new(mod, [unknown])?

horkhe commented 12 years ago

@eproxus so I will make mocks "honest" by default, and introduce an option to allow mocking of non-existing functions/modules. Though I find "unknown" a little bit confusing. What about "non_strict"?

eproxus commented 12 years ago

non_strict is much better.

horkhe commented 12 years ago

Yep, undefined_function is good.

horkhe commented 11 years ago

@eproxus I made mocks honest by default and changed the exception for the undefined function case as we discussed.

horkhe commented 11 years ago

@eproxus have you had a chance to take a look at the changes?

horkhe commented 11 years ago

@eproxus hey man, how are you? I hope you did not fall off the planet :-)

eproxus commented 11 years ago

@horkhe Haha, no. I just moved to Germany so I've been a bit busy. :-) I'll do a last sweep and then we'll merge.

horkhe commented 11 years ago

@eproxus Moved to Germany, that is cool. I suppose that was caused by a generous job offer, so my congratulations!

Back to business. The code is rebased and adjusted.

eproxus commented 11 years ago

@horkhe You, sir, are correct. :-)

horkhe commented 11 years ago

@eproxus I am genuinely curious if you new job is Erlang related?

eproxus commented 11 years ago

Yes, it is. I've started working at Wooga in Berlin. If you want a referral, let me know. :-)

horkhe commented 11 years ago

Thanks a lot for the suggestion! :-)