I love to confuse you again with this pretty piece of code from the
documentation
(http://ayende.com/Wiki/Rhino+Mocks+3.5.ashx)

public void When_user_forgot_password_should_reset_password()
{
    var stubUserRepository =
MockRepository.GenerateStub<IUserRepository>();

    // ...

    stubUserRepository.AssertWasCalled( x => x.Save(user));
}

And I have to say, I like it. I wouldn't do it all in the same test
method. But, I repeat myself, we have a test framework that sets up
test doubles. This could all be stubs, the framework does not have to
know if a single test wants it to be a stub or a mock. The test can
assert for calls, making it a mock, or not and it keeps being a stub.
You can argue that the name is wrong and should be
GenerateTestDouble<T>() or something. But I don't care about that.



On 11 Nov., 14:54, boo <[EMAIL PROTECTED]> wrote:
> The book 'the Art of Unit Testing' is worth every penny to help people
> who are young in unit testing get started (if you can get around the
> typos).  The author has a great way of explaining the diff's between
> mocks and stubs, it is also an excellent read for those who already
> know something about testing, or TDD in general, as they may find
> there is something they didn't think about.  95% of the example in the
> book that use a mocking framework use RhinoMocks, and that alone
> helped me to learn more about RhinoMocks than anything on the
> RhinoMocks site.
>
> To summarize from the book:
>
> 1.  Stubs just make happy noises for your test to pass.  They serve no
> other purpose than that.   You *never* test against a stub.
> 2.  Mocks are used for testing production code.  If you can't test
> against the real object, or it's cumbersome to test against the real
> object, you test against a mock.
> 3.  Use mocks and stubs only where you have to.   Just because you
> can, doesn't mean you should.
> 4   Only one mock per test.  If you have to use more than one mock you
> are either trying to test too much (test is testing more than a single
> function).  It could also be a sign that your method is attempting to
> do too much also, or a combination of the too.
> 5.  If you are truly only testing one thing in your tests, which you
> should be, the usuage of mocks and stubs fall in place if follow
> numbers 1-4.
>
> I whole heartidly believe you would be doing your group a disservice
> by not helping them to understand the difference between a stub and
> mock and you would probably hinder there ability to effectively use a
> mocking framework or write good tests.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Rhino.Mocks" group.
To post to this group, send email to RhinoMocks@googlegroups.com
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