Hello Denis,

thank you very much for your detailed explanations! This was really helpful for understanding how the behavior verification works. The implementation of ignoring of message sends basically worked fine this way.

Concerning this I would like to know if the following expression should pass or raise a WrongMessageSelector failure:

[:mock | mock message1; message2]  should strictly satisfy: 
[:mock | mock message2 useArbitrarily. mock message1.].

Actually the StrictBehaviorSpec requires that #message2 should be called before #message1. The arbitrarily property only specifies that the number of invocations of #message2 is not important. If so, the expression ought to fail with the invocation of #message2. Is that correct?

Best regards,
Robert

Am 19.09.2007 um 14:32 schrieb Denis Kudriashov:

2007/9/19, Robert Krahn <rksm@gmx.net>:
Hello Denis,

I dipped into your BehaviorMockup package and it seems really powerful. I like the block notation so that the expected behavior is stated after the exercised code. This way the tests can be more uniform (Four-Phase Test) and clearer.

One thing I didn't found out is how to have the mocks ignore certain message calls.
E.g. I want this to pass:
[:mock | mock m1; m2] should lenient satisfy: [:mock | mock m1]

I tried it the 'lenient way' as above but I get a SpecFailed: WrongMessageSelector. How can one do this?

Best regards,
Robert

p.s.
I wrote this mail to the squeak-dev mailing list first but forgot to add your mail address in the header so I am writing you an extra mail.

Hi Robert.

Expression

[:mock | mock m1; m2] should lenient satisfy: [:mock | mock m1]

creates and verifies LenientBehaviorSpec. It only defines arbitrary message sends order.

If you want mock ignores any message sends you must write something like:

[:mock | mock m1; m2] should lenient satisfy: [:mock | mock anyMessage. mock m1]

But it is not implemented yet. I think it takes a few hours work..

Possible implementation:
aMessageSend selector = #anyMessage ifTrue: [
messageSendSpec := MessageSendSpec new.
messageSendSpec add: (AnyMessageSemanticsSpec from: aMessageSend).
spec add: messageSendSpec.
 ^MessageSendSpecBuilder on: messageSendSpec]
 
messageSendSpec := MessageSendSpec withMessageSemanticsLike: aMessageSend.
spec add: messageSendSpec.
 ^MessageSendSpecBuilder on: messageSendSpec

With that stuff you can write specification for ignoring any message any times:

mock anyMessage useArbitrary

And use null object (with eating message sends):

mock anyMessage
useArbitrary
willReturn: Null new

Of course you can implement some nice helper messages for it.

Sorry for my english.

Best regards,
Denis