Hi Andrew,
> -----Original Message-----
> From: Andrew Batishchev [mailto:aba...@ta...]
> Sent: 20 June 2002 18:14
> To: vm...@oc...
> Subject: Stubs vs. Mock Objects
>
> Dear Vincent,
> The www.mockobjects.com site announces that you and Steve Freeman
> volunteered to share your vision of the subject.
>
> Before you publish "a page explaining the differences between Mock
Objects
> and Stubs as it is largely misunderstood" at (which we are waiting
for,
> patiently)
> could you be so kind to give us some advice where we can find some
> resources
>
> on this matter.
>
I would suggest you read the PDF first that is available on the web
site.
> Can we draw a fine line between these two concepts?
>
> Are mock objects extremely stupid and controlled by the unit test,
when
> stubs have some brains of their own?
>
yes!
Mock objects = stupid empty placeholders. They just have setters and
getters and no logic. They are 100% controlled by the test case, which
calls the correct methods to put them in a desirable state, tell then to
throw exception when such method is called, etc.
Stubs = simple implementation that is replacing the real one. It is
simpler than the real one but still implementing the same logic (at
least the same interface _seen from the outside_). Eg, A method might
throw an exception if such file is not present on disk and if it is then
return it's value. A stub would have some logic and perform an "if" to
implement that logic. A more intelligent stub would be able to be
controlled by some configuration flag or would provide an API .. haha
this is when the 2 concepts start to merge
Let's say that a Mock Objects is like a stub for which you would have
100% of its logic been made parametrizable as an API that is controlled
by the test case.
> Is it possible for you to describe this difference in some condensed
form,
> just by a couple of sentences?
>
> Sorry to bother you , but I am really desperate - I find myself in the
> middle of the new "To-Mock-or-not-to-Mock" holy war.
Either do in-container testing like Cactus or mock. Stubs is not a good
solution to me. It can be sometime for code that is not well written and
you want to see as a black box.
Cheers,
-Vincent
>
> Just links to the resources would be splendid.
>
> Thank you in advance
> Sincerely
>
> Andrew Batishchev
> Software developer
>
> Universal Tax Systems
> (706)624-4245 x 2265
>
>
> The information contained in this electronic message from Universal
Tax
> Systems, Inc., and any attachments, contains
> information that is confidential and/or privileged. If you are not
the
> intended recipient, you are hereby notified that
> any disclosure, copying, distribution or use of this information is
> strictly prohibited. If you have received this
> communication in error, please notify Universal Tax Systems, Inc.,
> immediately by e-mail or by telephone at 706/625-7757,
> and destroy this communication. Thank you.
>
|