[Pharo-project] Fwd: [Pharo-users] TestMock: a full featured mock testing framework now available in SqueakSource

Stéphane Ducasse stephane.ducasse at inria.fr
Wed Nov 24 14:30:37 CET 2010


By the way dennis did you start to write a chapter on Mocks?

Stef

On Nov 24, 2010, at 11:21 AM, Dennis Schetinin wrote:

> I'm aware of this idea. It is very interesting. Actually, I often meet this pattern in practice. But I don't see how it is connected with Mocks :)
> 
> 2010/11/24 Tudor Girba <tudor.girba at gmail.com>
> Given this discussion, I would like to encourage you to take a look at Phexample by Adrian Kuhn and Niko Schwarz, based on previous work of Markus Gaelli. The basic idea is that there is no distinction between setup and tests. They are all examples, and examples are built on top of each other.
> 
> Phexample is completely compatible with SUnit. It also comes with a fancier API, but even if you would like to debate this API, I believe it is a nice thing that we should look more closely into.
> 
> Here are two examples checking an implementation of Stack. The first one creates the stack and checks that it should be empty, and the second one checks the pushing behavior:
> 
> ForExampleStack>>shouldBeEmpty
>        | stack |
>        stack := Stack new.
>        stack isEmpty should beTrue.
>        stack size should = 0.
>        ^ stack
> 
> ForExampleStack>>shouldPushElement
>        | stack |
>        stack := self given: #shouldBeEmpty.
>        stack push: 42.
>        stack isEmpty should not beTrue.
>        stack size should = 1.
>        stack top should = 42.
>        ^ stack
> 
> More information can be found here:
> http://smalltalkthoughts.blogspot.com/2009/11/phexample-because-examples-expand-on.html
> 
> You can get it by simply:
>  Gofer new
>  squeaksource: 'phexample';
>  addPackage: 'Phexample';
>  load
> 
> 
> Cheers,
> Doru
> 
> 
> On 24 Nov 2010, at 08:28, laurent laffont wrote:
> 
> > I agree with you Dennis. TDD practices are far ahead in Ruby / Java / Python world.
> >
> > BUT IMHO can be a real cool neaty great platform for TDD because we have: dynamic development.
> >
> > What I think we miss:
> > - put  a Mock framework in PharoCore - Mocks should be a standard tool even for low-level stuff
> > - introduce pragmas to declare tests / setUp / tearDown methods so I can write
> >
> > AddressBookWithLaurentAndDennis>>createAddressBook
> >   <setUpTest>
> >   bla bla
> >
> > AddressBookWithLaurentAndDennis>>shouldHaveNumberOfContactsAnswersTwo
> >   <test>
> >   blabla
> >
> > AddressBookWithLaurentAndDennis>>ifDennisRemovedNumberOfContactsShouldAnswersOne
> >   <test>
> >   bla bla
> >
> >
> >
> > - (harder) interface to / creation of an executable requirements / BDD framework like Cucumber http://cukes.info/
> >
> > Laurent
> >
> >
> > On Wed, Nov 24, 2010 at 4:31 AM, Dennis Schetinin <chaetal at gmail.com> wrote:
> > As for me, I'm simply unable to establish smooth test-driven process without Mocks. I think it does not depend on language at all.
> >
> > Without mocks I have to divide the task I have into smaller independent parts. It's actually an up-front design. I can make a mistake (I usually do); even worse it's often just impossible to accomplish because too many subcomponents usually interact thoroughly and I simply don't know which one to implement first :). So, without mocks I have to code bottom-up, from details to general. This is unnatural and error-prone.
> >
> > With mocks I can start directly from the task I have. I get a use case and write a test for the one. Creating the test I detect subcomponents needed, understand how they should interact and document that in the same test. As those subcomponents do not exist yet, I have to specify them and their behavior right in the test (if I don't want to break the process I've just started). That's why I really need mocks. Then I can take another use case or implement one of the mocks I used as a real object and so on. Thus, mocks allow me to go top-down and implement only the things I really need, not the things I think I'll need.
> >
> > Are there other, maybe better, approaches?
> >
> > Concerning TDD popularity… I'm not sure TDD plays the role it should in Smalltalk community.
> >
> > Messing with Smalltalk for about 7–8 years, I can't say I often see real TDD code. About 50–70% (depending on Smalltalk dialect) of frameworks I use have no tests at all. The rest often looks being tested a posteriori. Perhaps, Pharo is the only exclusion…
> >
> > And if TDD is really popular and widely used, why do we have so much regression bugs even in core subsystems even in commercial Smalltalks?
> >
> > Please, correct me if I'm wrong.
> >
> > 2010/11/23 laurent laffont <laurent.laffont at gmail.com>
> >
> > On Tue, Nov 23, 2010 at 5:39 PM, Luc Fabresse <luc.fabresse at gmail.com> wrote:
> > Hi Dennis,
> >
> >  Yes, TDD is highly popular and encouraged in the Smalltalk community.
> >  And mocks are not necessary in most cases.
> >
> >
> > Hi Luc,
> >
> > why Mocks are less necessary in Smalltalk than in other (Ruby/Python/whatever...) languages ? Do you have some examples / link ?
> >
> > Sometimes I think a mocking library should be in PharoCore so I don't need to write my own mocks.....
> >
> >
> > Cheers,
> >
> > Laurent
> >
> >
> >
> >
> > #Luc
> >
> >
> > 2010/11/23 Dennis Schetinin <chaetal at gmail.com>
> >
> > How is it compared to Mocketry (http://www.squeaksource.com/Mocketry.html)? SMock?
> >
> > BTW, isn't TDD without mocks a bit incomplete? And is TDD popular among smalltalkers actually?
> >
> > 2010/11/22 Mariano Martinez Peck <marianopeck at gmail.com>
> >
> > This is cool Anindya. I don't need mocks right now, but I will keep it in mind!
> >
> > I cc'ed Pharo-dev mailing list.
> >
> > Cheers
> >
> > Mariano
> >
> > ---------- Forwarded message ----------
> > From: Anindya Haldar <anindya_haldar at yahoo.com>
> > Date: Mon, Nov 22, 2010 at 10:11 AM
> > Subject: [Pharo-users] TestMock: a full featured mock testing framework now available in SqueakSource
> > To: pharo-users at lists.gforge.inria.fr
> >
> >
> > Dear Pharoers,
> >
> > TestMcok is a full featured mock based test framework that I am very glad to contribute to the community. It is in squeaksource under the project name TestMock. Please feel free to try it, and feedback will be greatly appreciated. The wiki section includes a brief how-to guide with code examples.
> >
> > Regards,
> > Anindya Haldar
> >
> >
> >
> >
> > _______________________________________________
> > Pharo-users mailing list
> > Pharo-users at lists.gforge.inria.fr
> > http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-users
> >
> >
> >
> >
> >
> > --
> > Dennis Schetinin
> >
> >
> >
> >
> >
> > --
> > Dennis Schetinin
> >
> 
> --
> www.tudorgirba.com
> 
> "In a world where everything is moving ever faster,
> one might have better chances to win by moving slower."
> 
> 
> 
> 
> 
> 
> 
> -- 
> Dennis Schetinin





More information about the Pharo-project mailing list