-
Notifications
You must be signed in to change notification settings - Fork 463
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
Multiple "when" block for single "then" block #1545
Comments
Can you share MCVE to illustrate your use case a bit more. |
I can imagine two solutions without changes in Spock. Solution 1: Use helper methods. Put the Solution 2: work with closures like you tried, just do it correct. :-D foo | bar
{ 'bam' } | 'baz' Unfortunately the Groovy lexer does not see this as the variable name foo | bar ;
{ 'bam' } | 'baz' ; or _____________________
; foo | bar ;
; { 'bam' } | 'baz' ; or bar | foo
'baz' | { 'bam' } or _ | foo | bar
_ | { 'bam' } | 'baz' |
Is your feature request related to a problem?
I have a lot of situations and I can't find my problem solution in documentation.
The problem is:
I have a lot of tests where I expect the same errors and data with similar, or the same given data. In these situations I have everywhere the same given and then blocks for each when block (when is ussualy invoking one method). In these situations I have a lot of boilerplate in test code which is not readable.
Describe the solution you'd like
I tried to use where block and give Clousure, or Runnable, then invoke it in when block, but iI got "Groovyc: Header of data table may only contain variable names"
The best in use will be multiple when: labels for every tested method
In documentation I found only multiple when: then:, but multiple when: for the same then: is needed.
Do you have some idea?
Describe alternatives you've considered
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: