spockframework / spock

The Enterprise-ready testing and specification framework.
https://spockframework.org
Apache License 2.0
3.56k stars 470 forks source link

Strict Expectations would be good #240

Closed robfletcher closed 9 years ago

robfletcher commented 9 years ago

Originally reported on Google Code with ID 118

Describe the new feature you have in mind.

Hi There, i appreciate the spock framework, i am using it, and it's look promising.
before spock i have used jmock. which is pretty good as well. in spock frame work i
am missing the strict expectation feature which is available in jmock. it would be
nice if you have such a kind of feature in
spock, with the ability to turn on / turn off strict expectation. 

Which particular problem would this feature solve for you?

jMock automatically verifies any Verifiable objects stored in its instance variables.
This helps the user avoid common errors caused by forgetting a verify statement. This
automatic verification can be overridden if necessary. if spock also has this kind
of of feature it would be great.. even jmockit also supporting these kind of features

Please provide any additional information below. You can also assign
labels.

Reported by Mr.Amuthan on 2010-08-11 04:52:14

robfletcher commented 9 years ago
Here is how you do this with Spock:

when:
...
then:
... // the interactions that you expect
0 * _ // no other interactions

Or, if you also have interactions defined outside a then-block (say in setup:)

setup:
... // the interactions that you expect
0 * _ // no other interactions

when:
...
then:
... // additional interactions may go here

Reported by pniederw on 2010-08-11 10:42:20

robfletcher commented 9 years ago
Wow... Thank you.. It's working for me.. Great.. Spock is rocking..

Reported by Mr.Amuthan on 2010-08-12 04:47:59

robfletcher commented 9 years ago
Thanks for the praise!

Reported by pniederw on 2010-08-12 14:13:12