@Tim Enforce the rules to your team. Don't confuse them with "stubs" always because there is a lot out there in the internet about mocks and stubs. That might confuse them more.
If the SUT needs a dependency to return something (a la canned answers) and not care about anything else it does, use stubs. Think if it just needs to make happy noises :) If the SUT needs a dependency and you are "expecting" the dependency to call a method with certain arguments, use mocks and verify. I tend to lean towards more stubs vs mocks because it makes your test less brittle. If you are using mocks, have no more than _1_. If you have more than one, I think it's a more of a question of what you are testing. If you need more guidance, check the docs: http://ayende.com/wiki/Rhino+Mocks+3.5.ashx#UsageGuidance On Nov 7, 11:17 am, "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 -~----------~----~----~----~------~----~------~--~---
