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

Please provide data variables in PreconditionContext #1085

Open
Vampire opened this issue Jan 27, 2020 · 4 comments
Open

Please provide data variables in PreconditionContext #1085

Vampire opened this issue Jan 27, 2020 · 4 comments

Comments

@Vampire
Copy link
Member

@Vampire Vampire commented Jan 27, 2020

I have a test with where-block where one of the tests fails on Java 8 due to a JRE bug that is fixed on Java 9.
It would be great if I could ignore only the iteration that fails on Java 8 on Java 8, something like @IgnoreIf({ jvm.java8 && (userId == 'foo') }) where userId is the data variable and 'foo' its value for the bug-triggering case.

While reporting this, I observed that this also implies a request to check IgnoreIf per iteration, not per feature. :-)

@Vampire

This comment has been minimized.

Copy link
Member Author

@Vampire Vampire commented Jan 27, 2020

Of course assume... can be used for this too, but it would imho cleaner to be able to specify it as annotation, especially in cases where one would use PendingFeatureIf once it is added instead of IgnoreIf :-)

@leonard84

This comment has been minimized.

Copy link
Member

@leonard84 leonard84 commented Feb 4, 2020

So how would you handle the cases where you don't want to execute the where-blocks at all?

@Vampire

This comment has been minimized.

Copy link
Member Author

@Vampire Vampire commented Feb 4, 2020

Uhm, good question, didn't think about that.
How about checking whether the closure references a data variable and if not, apply it to the whole feature?
As Groovy code is pretty dynamic this can probably not be done upfront, but the names of the data variables are known, aren't they?
So you could evaluate the closure for the feature with dummy properties for the data variables, if one of these gets used during evaluation, you know data variables are used and check the closure per iteration instead. If none of the dummy variables was used, no data variable is used and the closures result can be effective on the feature right away.

@leonard84

This comment has been minimized.

Copy link
Member

@leonard84 leonard84 commented Feb 14, 2020

I'm not really sure I like this magic, it might be simpler to just have a dedicated extension. Or you could just throw a TestAbortedException (Spock 2.0) yourself. This maybe not as fancy but I don't know how often this feature would get used compared to the added complexity of the extension code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.