Fowler on Mocks

Zulq Alam zulq at orange.net
Wed Aug 9 07:40:19 UTC 2006


After looking at it, I can see you are right.

With regards to mocks, the interesting part for me is the ability to 
change factors that effect the execution without creating a new class or 
writing code to manipulate the stub again and again, i.e. the stub. I 
would use these in state based testing as a better stub.

With regard to Teachable, I think my implementation earlier in the 
thread is more flexible as it can deal with methods and simple arguments 
rather than just selectors (as I understood Teachable).

Markus Gaelli wrote:
>
> On Aug 8, 2006, at 11:31 PM, Zulq Alam wrote:
>
>> This should help you Stéphane...
>>
>> http://www.squeaksource.com/Teachable/
>
> ...but note that these teachables help us to build stubs  and not _mocks.
>
> Fine for me: Whereas I can see the value of stubs for stubbing 
> external systems (like web-pages as described above) I stick like 
> Fowler with the state-based testers.
> Don't know why I would want to ensure that some specific methods are 
> called during my code, I prefer to check the result.
>
> As for the example used in the Oopsla paper of the mock Proponents (a 
> cache - the mocks ensure that objects are not fetched again from the 
> outside if already present (blurring the difference between mocks and 
> stubs again of course)) I prefer to test if I get the right result 
> within a certain time, both possible without mocks.
> http://www.jmock.org/oopsla2004.pdf
>
> If I later decide that I can get rid of the caching and always fetch 
> the data from outside, I can reuse my state-based test whereas I would 
> have to throw away the mocks.
> As Fowler says I "am concerned about the consequences of coupling 
> tests to implementation."
>
> And aren't we taught to write method names which reflect the "what" 
> and not the "how"?
>
> Cheers,
>
> Markus
>
>>
>>
>> stéphane ducasse wrote:
>>> There is a package somewhere with teachable objects indeed. I'm 
>>> interested to get my hands on it :)
>>>
>>> Stef
>>>
>>> On 8 août 06, at 18:27, Brent Pinkney wrote:
>>>
>>>> On Tuesday 08 August 2006 18:02, Mathieu wrote:
>>>>> stéphane ducasse a écrit :
>>>>>> markus sent me this nice article on mocks...
>>>>>>
>>>>>>
>>>>>>> http://www.martinfowler.com/articles/mocksArentStubs.html
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>> Thank intresting!
>>>>>
>>>>> Do we have a way to define mock in Squeak?
>>>>
>>>> I recall something on the list about a Teachable class which I 
>>>> suspect could get us most of the way.
>>>>
>>>> Brent
>>>>
>>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> --No virus found in this incoming message.
>>> Checked by AVG Free Edition.
>>> Version: 7.1.405 / Virus Database: 268.10.8/413 - Release Date: 
>>> 08/08/2006
>>>
>>>
>>
>>
>
>
>
>
>
>
>
>
> --No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.1.405 / Virus Database: 268.10.8/413 - Release Date: 
> 08/08/2006
>
>




More information about the Squeak-dev mailing list