[Esug-list] Fwd: Re: Proposal for Mock Objects at ESUG 2011

Yann Monclair yann at monclair.fr
Fri May 27 16:25:14 EDT 2011


>
>  Lastly, mocks document the protocols your objects use to collaborate
>> with each other. They are much more than post-fact assertions.
>>
>
> I don't understand this... why would I use mocks to document protocolos if
> I alredy have the real objects with their protocol and the tests documenting
> them with concrete examples?
>

The tests will document the use of the methods, but mocks allow you to
ensure the separation of public and private protocols by only offering the
public protocol on your mocks.
If your code breaches this separation, your tests will fail with MNUs.
Obviously, it only works if the mock object is implemented respecting that
separation ;-)

Cheers,
Yann

On Fri, May 27, 2011 at 10:05 PM, Hernan Wilkinson <
hernan.wilkinson at 10pines.com> wrote:

> Hi Frank,
>
> On Fri, May 27, 2011 at 4:42 PM, Frank Shearar <frank.shearar at gmail.com>wrote:
>
>> You miss the point of mocks. Mocks are there to allow you to test your
>> code quickly and cheaply against things that may not work in a quick
>> manner.
>>
>
> well, not really, I mean 23.000 tests in 7 minutes I think is quick enough
> :-)
> I'm not saying mocks are not important, but I think sometimes they are
> overused, that's all.
>
>
>>
>> Further, they allow you to isolate yourself from external systems. If
>> you need a database running for your tests to pass, you are not unit
>> testing, but integration testing. You do need to do both, but they
>> serve different purposes.
>>
>
> I agree, and I think I mentioned that... we use test doubles (not only
> mocks) for those types of tests.
>
>
>> Lastly, mocks document the protocols your objects use to collaborate
>> with each other. They are much more than post-fact assertions.
>>
>
> I don't understand this... why would I use mocks to document protocolos if
> I alredy have the real objects with their protocol and the tests documenting
> them with concrete examples?
>
>
>
>> Someone's already mentioned the excellent Growing Object Oriented
>> Systems Guided by Tests (Tim wrote the afterword for it).
>>
>
> yeah... but I don't like too much what they proposed is that book :-) (I
> told that to Tim :-)) but that is another story :-)
>
>
>>
>> My two cents? We have at least the beginnings of a framework inside
>> SSpec, a project which dearly needs some love and attention. It's
>> globally writable so contributing to it is easy.
>>
>> In particular, when next I get a chance - hopefully this next month -
>> I'd like to address some of its quirks, split SSpec's DSL from the
>> mocking library, integrate SSpec into TestRunner (or at least make the
>> expectations runnable from TestRunner), and make sure the
>> TextTestRunner still works.
>>
>> What I don't want to see is everyone publishing their own incompatible
>> frameworks or, just as bad, noone doing anything because "oh we don't
>> need mocks". We do need them, and we need a well-implemented
>> feature-complete cross-dialect framework.
>>
>
> hey, I'm not saying this should not be done, just only I don't see mocks as
> important as some people see them, that's all.
>  I'd like to have a "well-implemented feature-complete cross-dialect
> framework" mock model of course.
>
> Bye!
> Hernan.
>
>
>> frank
>>
>> On 27 May 2011 19:41, Hernan Wilkinson <hernan.wilkinson at 10pines.com>
>> wrote:
>> > Hi Dennis,
>> >  I completely agree with Niall... I participated in the development of a
>> > systems, in VASmalltalk & GemStone, that has 23.000 tests that run in 7
>> > minutes and we hardly needed to use mocks... we mostly needed to
>> > have polymorphic objets with the real ones and sometimes we used the
>> same
>> > test to do it and sometimes we just used the real ones that were created
>> > using resources... I prefer to use real objects instead of mocks or test
>> > doubles because when using test doubles (which includes mocks) you are
>> not
>> > testing the real thing, so for example, I do not use test doubles for
>> > objects that are part of the system I'm writing but only for objects
>> outside
>> > the system.
>> >  My experience of teaching/coaching TDD shows that test doubles are more
>> > important due to its difficulty of using, in statically typed languages,
>> > which makes sense because the coupling between the "client" object and
>> the
>> > "server" object is the variable's type instead of only the messages that
>> are
>> > sent.
>> >  I also believe that TDD is popular in Smalltalk... why do you think it
>> is
>> > not?
>> >  Bye!
>> >  Hernan.
>> >
>> > On Fri, May 27, 2011 at 10:16 AM, Niall Ross <nfr at bigwig.net> wrote:
>> >>
>> >> Dear Dennis,
>> >>
>> >> > I'd like to explore interest to Mock Object in Smalltalk society. I'm
>> >> > currently working on the topic, preparing a paper and presentation
>> >> > targeting at ESUG 2011.
>> >>
>> >> Sounds interesting.
>> >>
>> >> Steve Freeman (via Joseph Pelrine) wrote:
>> >>
>> >>> You should talk to Tim, he wrote a mocks library in about 3 classes
>> >>> (which is what it should take). He also has some interesting
>> experience from
>> >>> the Kapital project that doesn't have unit tests.
>> >>
>> >>
>> >> Tim Mackinnon mentions mock objects in his talk 'Expressive Testing and
>> >> Code for Free' at ESUG 2007 (report reachable from
>> >> http://www.esug.org/Conferences).
>> >>
>> >> You remark
>> >>
>> >> > Apparently, Mocks technique is not popular tool among Smalltalkers.
>> >>
>> >> and Steve, noting that, says
>> >>
>> >>>
>> >>> I hadn't realised that the ST world was behind in this respect.
>> >>
>> >> I note that one or two who replied to your earlier post said they had
>> not
>> >> needed Mocks, or found them brittle, but I don't think the technique is
>> >> _unpopular_ in Smalltalk.  My own take is
>> >>
>> >> 1) Smalltalk's power means mocks are not needed as often.  Many a time,
>> >> you can get at what you need directly, or by use method wrappers to
>> make the
>> >> real objects (or the routes to them) act momentarily as mocks.
>> >>
>> >> Here, I may be saying the same as you:
>> >>
>> >>>> Yes, Smalltalk is great language and it has great tools.
>> >>>> This damps some aspects of the problems TDD and Mocks address, but
>> for
>> >>>> sure does not remove them totally.
>> >>>
>> >>
>> >> 2) Another dynamic language feature is that you can more easily
>> structure
>> >> tests so the same test can be run against both the mock and the real
>> object
>> >> when the latter is available.  (The approach is the same as in my talk
>> >> "eXtreme UI Testing" at Smalltalk Solutions 2007, also reachable from
>> the
>> >> http://www.esug.org/Conferences page.)
>> >>
>> >> These features may sometimes make people less thorough in setting up a
>> >> full mocks framework for their application's tests.
>> >>
>> >>
>> >>>> It even seems (to me), TDD is not as widely used as it could and
>> should
>> >>>> be (despite the fact it was born in Smalltalk).
>> >>>
>> >> I don't think TDD is in the least unpopular or unrespected in
>> Smalltalk.
>> >>  However I'm sure you are right when you say it "is not as widely used
>> as it
>> >> could and should be", though I'd be surprised if that were more true of
>> >> Smalltalk than of other languages.
>> >>
>> >>>> I have been using TDD and
>> >>>> Mocks for many years in different projects with Smalltalk and other
>> >>>> languages. Sometimes it was hard, sometimes I was even giving it up,
>> but
>> >>>> by now I think I have sufficient experience to state that TDD in
>> general
>> >>>> and Mock Objects specifically do deserve (at least) more attention by
>> >>>> Smalltalkers.  ... I was most productive in Smalltalk when I used
>> >>>>  "classic TDD" and mocks in conjunction.
>> >>>
>> >> If your talk uses your experience to illuminate why what we "could and
>> >> should be" doing was "sometimes ... hard ... even giving it up", but
>> "most
>> >> productive", that might be very useful to others.
>> >>
>> >>            Yours faithfully
>> >>                  Niall Ross
>> >>
>> >>
>> >> ______________________________________________________________________
>> >> This email has been scanned by the MessageLabs Email Security System.
>> >> For more information please visit http://www.messagelabs.com/email
>> >> ______________________________________________________________________
>> >>
>> >> _______________________________________________
>> >> Esug-list mailing list
>> >> Esug-list at lists.esug.org
>> >> http://lists.esug.org/mailman/listinfo/esug-list_lists.esug.org
>> >
>> >
>> >
>> > --
>> > Hernán Wilkinson
>> > Agile Software Development, Teaching & Coaching
>> > Mobile: +54 - 911 - 4470 - 7207
>> > email: hernan.wilkinson at 10Pines.com
>> > site: http://www.10Pines.com
>> >
>> > _______________________________________________
>> > Esug-list mailing list
>> > Esug-list at lists.esug.org
>> > http://lists.esug.org/mailman/listinfo/esug-list_lists.esug.org
>> >
>> >
>>
>
>
>
> --
> *Hernán Wilkinson
> Agile Software Development, Teaching & Coaching
> Mobile: +54 - 911 - 4470 - 7207
> email: hernan.wilkinson at 10Pines.com
> site: http://www.10Pines.com <http://www.10pines.com/>*
>
>
> _______________________________________________
> Esug-list mailing list
> Esug-list at lists.esug.org
> http://lists.esug.org/mailman/listinfo/esug-list_lists.esug.org
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.esug.org/pipermail/esug-list_lists.esug.org/attachments/20110527/9ed8692d/attachment-0002.html>


More information about the Esug-list mailing list