On 19 Oct 2009, at 08:48, Francis Fish wrote:
> I've been teaching this to a PHP team in my current role so very > useful. I also came across this Martin Fowler thing about the > difference between mocks and stubs, where he says that mocks > generally allow you to create expectations ans stubs are more about > stubbing out behaviour:http://martinfowler.com/articles/ > mocksArentStubs.html Hi Francis Glad it was useful. I found that article useful too, but I'm unconvinced it's beneficial to make a distinction between a mock and a stub object. (However, Jamie van Dyke pointed out in the questions that after using Mocha, he *did* find it useful to separate them*, so maybe it depends on your choice of mocking framework as well as language.) The distinction is even more blurred in RSpec (and Ruby), as you can set a method stub or expectation on *any* object, so it's hard to argue that it's the mock that is providing the behaviour or verification. And since the visible behaviour is all that matters (until things go wrong), I find it hard to argue that they should be considered separate things. It feels to me to be a legacy from the early days of writing mocks in Java. I would change my mind if I saw a type of mock where it was clearly the mock itself providing the verification, and there was value in that implementation**. Cheers Ashley * Corrections welcome if I remembered that point wrong ** The only other mocking framework I've used was the C# RhinoMocks library, but that was a good while ago, and I can't remember how the verification integrated into MbUnit. -- http://www.patchspace.co.uk/ http://www.linkedin.com/in/ashleymoran http://aviewfromafar.net/ --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "NWRUG" 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/nwrug-members?hl=en -~----------~----~----~----~------~----~------~--~---
