Hey Ashley, Thanks for the NWRUG talk - very well done I think :) What I think might be nice is some sort of follow up that's code-based - a piece of code with some dependencies that needs testing.. Perhaps you could show the code run and pass, and then show just how brittle the test is and how much of a PITA it is to set up, and then show how the test can be improved by using a stub. Then get into "advanced" usage by using a mock to test the behavoir... Just a thought ;)
As for the diference between mocks and stubs, its a source of confusion for a lot of people I think, me included. I found this artcile a little useful: http://weblogs.asp.net/rosherove/archive/2007/09/16/mocks-and-stubs-the-difference-is-in-the-flow-of-information.aspx- its a .net blog but it illustrates the differences quite well to me. I suppose its important to differenciate between mocks and stubs as long as the testing/mocking/stubbing frameworks out there differenciate, although I'm not sure what there is to be gained by having 2 different terms, whats wrong with "there are mocks, oh and by the way you can also test the expected behavoir with them" ? Matt. On Mon, Oct 19, 2009 at 1:20 PM, Ashley Moran <[email protected] > wrote: > > > 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/ > > > > > > > > > > > -- :O) Matt Roberts --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
