Ayende,
Are stubs and mocks in Rhino now identical, technically? Are they just
synonyms?
I fully agree with Shane. I think that stubs are useful as a separate
non-assertable mechanism to satisfy dependencies that don't need to be
tested.
If stubs and mocks can both be asserted on, why have both? It's just
syntactic noise and confusing. You might as well remove one of them
from the code base completely and instead of saying "Use Mocks when
you care and Stubs when you don't", just say "Assert when you care".
I suggest that rhino choose one of 2 clear paths instead of walking
the ambiguous middle road:
1. Remove either stubs or mocks completely.
2. Enforce the perceptual difference by making stubs non-assertable.
shovavnik
On Nov 7, 6:17 pm, "Tim Barcz" <[EMAIL PROTECTED]> wrote:
> "and I got feature request to be able to assert of stub calls."
>
> If you can do asserts on calls with a stub does that negate the value of a
> mock?
>
> If we say mocks are for interaction, couldn't you say (given that you can
> assert on a stub), use stubs always, use an AssertWasCalled when you want to
> verify interaction.
>
> On Fri, Nov 7, 2008 at 8:08 AM, Ayende Rahien <[EMAIL PROTECTED]> wrote:
> > Because there isn't really much of a difference between the two, and I got
> > feature request to be able to assert of stub calls.
>
> > On Fri, Nov 7, 2008 at 4:03 PM, Shane Courtrille <
> > [EMAIL PROTECTED]> wrote:
>
> >> Which to me is the standard difference between the two.
>
> >> The question is why does the interface for a stub have to support
> >> operations which are the domain of a mock object? When a new comer looks
> >> at
> >> a Stub shouldn't they be able to tell the difference without having to deal
> >> with the mental baggage of "Hey wait.. a stub looks a lot like a mock to
> >> me".
>
> >> Shane
>
> >> On Fri, Nov 7, 2008 at 6:15 AM, Ayende Rahien <[EMAIL PROTECTED]> wrote:
>
> >>> The main thing is a concpetual difference.I would use stub if I don't
> >>> care about what is going to happen
> >>> I would use a mock if I do care.
>
> >>> On Fri, Nov 7, 2008 at 2:05 PM, Tim Barcz <[EMAIL PROTECTED]> wrote:
>
> >>>> I am working on a presentation and was about to make the assertion,
> >>>> "stubs can't have expectations set on them". I decide to double check
> >>>> myself and run the following code and see that I can set expectations.
> >>>> (Removing the call to logger.Log in the Order method causes the test to
> >>>> fail).
>
> >>>> [TestFixture]
> >>>> public class Stubs
> >>>> {
> >>>> [Test]
> >>>> public void CreateStub()
> >>>> {
> >>>> var logger = MockRepository.GenerateStub<ILogger>();
>
> >>>> var svc = new OrderService(logger);
>
> >>>> svc.Order();
>
> >>>> logger.AssertWasCalled(x=>x.Log("hello"));
> >>>> }
>
> >>>> public class OrderService
> >>>> {
> >>>> private readonly ILogger logger;
>
> >>>> public OrderService(ILogger logger)
> >>>> {
> >>>> this.logger = logger;
> >>>> }
>
> >>>> public void Order()
> >>>> {
> >>>> logger.Log("hello");
> >>>> }
> >>>> }
> >>>> }
>
> >>>> public interface ILogger
> >>>> {
> >>>> void Log(string message);
> >>>> }
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---