Skip to content

Why is the second execution of the when condition not updated, or is it the first when condition? #1835

Answered by Vampire
905174278 asked this question in Q&A
Discussion options

You must be logged in to vote

You should probably make this as a data-driven test instead, or split it into multiple tests.
That it does not work as you expect is because you cannot override interactions like that.
The interaction from the first when: is still in place and is used, because it does not have any cardinality.
If you want to override previous interactions, you need to do that in then: like described at https://spockframework.org/spock/docs/2.3/all_in_one.html#_where_to_declare_interactions.

But as I said, you should most probably either split the test or make it data-driven anyway, then the second test can be checked, even if the first already failed, and then they are properly isolated.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by leonard84
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants