Like Tim I understand the concern you have with missed calls as I started
using Rhino Mocks with the same concern.  With that said I agree with
everything Tim has said.  Experience has shown over years of using Mocking
that strict mocks actually leads to very strong test smells.  If we look at
the bible of testing 'xUnit Test Patterns' the closest test smell which I
think matches when we say brittle tests is Fragile Tests.  Fragile tests are
defined as 'A test fails to compile or run when the SUT is changed in ways
that do not affect the part the test is exercising'.  As Tim mentions this
behavior actually occurs as a result of StrictMocks.  When using StrictMocks
every call that occurs must be recorded.  At first this doesn't seem so bad
until you take into account the practice of asserting one thing per test.
This includes mock usage.  But because you are using a StrictMock every test
must include expectations for every single call that occurs.  This means
that if you are asserting a few different mock calls every single test fails
when you change a single line of code rather then the one test that should
fail.  This is a textbook example of Fragile Tests.

I would also mention that having switched to DynamicMocks awhile ago I can
happily say that I have never ran into the problem we all started out being
concerned with.  The use of Dynamic Mocks has proven itself to be quite safe
and lead to tests which are much more trustable (a key requirement of good
tests).

Regards,

Shane

On Sun, Mar 22, 2009 at 5:52 PM, (luKa) <[email protected]> wrote:

>
> Ciao from Stockholm,
>
>     I'm reading this
>
> http://ayende.com/wiki/Rhino+Mocks+3.5.ashx#CreateMockisdeprecated,replacedbyStrictMockTheuseofStrictMockisdiscouraged
> and I've noted that dynamic mocks can lead to flawed tests.
>
> Going on with the example in the link, suppose that with the evolution
> of the sw the method RevertUserChanges() is added to the
> IUserRepository interface.
> Then a dev introduce a bug in the LoginController.ForgotMyPassword()
> so that RevertUserChanges() get called by mistake.
> As I understood the Dynamic Mock now wont raise an error because of
> this call to RevertUserChanges().
>
> I feel that brittle tests are a smell for responsibilities that must
> be decoupled instead of a need for object dynamically mocked. What you
> think ?
> when I think about exception I see a similarity, I prefer to get the
> exception instead of running the risk of catching and ignoring an
> important problem.
>
> The agile principle here is feedback and fail fast
>
>
>
> Luca Minudel
> Stockholm, Sweden GMT+1
> http://www.linkedin.com/in/lucaminudel en-GB
> http://blogs.ugidotnet.org/luKa/ it-IT
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Rhino.Mocks" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/RhinoMocks?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to