-
Notifications
You must be signed in to change notification settings - Fork 471
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ability to override stubbing for given parameters #26
Comments
Doing this in a then-block is a feature, not a workaround. There is a feature request to allow overriding of interactions declared in a setup-method in the test method, but so far it hasn't been implemented. PS: Please use http://issues.spockframework.org instead of this tracker, which was activated accidentally. |
Stubbing in |
By default Spock uses a match first algorithm to determine the defined return value of a method. So whenever there are multiple defined return values, it will pick the first (that is not exhausted). This change enables a user to change this to a match last algorithm. So Spock will pick the last defined return value (that is not exhausted). This enables easy overriding of default return values. As requested in issue spockframework#26, spockframework#251, spockframework#321 and spockframework#962.
As presented on the mailing list, sometimes it is useful to override (not append) a stubbing on a Mock for given parameters (or just for any parameter).
It could use a construction like normal stubbing with >> (but with different operator) or be implemented in some other way.
There is a workaround with subbing in a then block, but it is not intuitive and doesn't look good :).
The text was updated successfully, but these errors were encountered: