Skip to content
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

Closed
szpak opened this issue Nov 28, 2013 · 2 comments
Closed

Ability to override stubbing for given parameters #26

szpak opened this issue Nov 28, 2013 · 2 comments

Comments

@szpak
Copy link
Member

szpak commented Nov 28, 2013

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 :).

@pniederw
Copy link
Contributor

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.

@tadaskay
Copy link

tadaskay commented May 7, 2015

Stubbing in then block is counter-intuitive when reading a specification. It should be possible to override stubbing for specific method in setup / given. Would you consider re-opening this issue?

BoukeNijhuis added a commit to BoukeNijhuis/spock that referenced this issue Sep 26, 2020
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants