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
Increase Groovy version to 3.0.6 and give condition closures access to the specification instance #1204
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1204 +/- ##
============================================
+ Coverage 76.49% 76.50% +0.01%
- Complexity 3751 3754 +3
============================================
Files 405 405
Lines 11432 11437 +5
Branches 1396 1396
============================================
+ Hits 8745 8750 +5
Misses 2199 2199
Partials 488 488
Continue to review full report at Codecov.
|
Actually this was an intended change. For both we create the closure instances without For the For the We could also make Or actually we could make the So to summarize the multiple-choice options we have are:
@leonard84 & @szpak what do you think? |
IMHO we should only set the class as owner, doing it for the instance causes the setup phase to run, e.g., starting a spring context, only to abort again. And you'd either have to scan the whole class for valid properties/methods beforehand or you'd continue only to fail later anyway. |
In the For the Actually the logic is already present almost completely due to the shiny new data variable support. |
So you would not inspect the class to see if the missing property would even be available? Same with missing method? |
No, I think that would be unnecessary complex, superfluous, wasted time and too error prone. If it fails due to missing property or method, then it could be that it was not a valid call to the test instance, then it will do the check again later and fail again. In that case this means it is a programming error in the test, so it has to be fixed to use a valid property or method. Once the test is fixed, it will only fail with missing property or missing method exception if an correct access was made. Checking that it was a valid access before checking again later would only be a waste of processing, besides that it is too error prone with the dynamic capabilities of Groovy. For the data variables the check was easy and reliable, as we know the data variables that exist and there is not much magic that could happen additionally. |
Any other thoughts @spockframework/supporter |
If the implementation is analogous to |
(Latest groovy is 3.0.6, by the way) |
You are right @henrik242, but there is no reason to depend on a newer Groovy version if there is not something fixed that is essential for Spock imho. |
For me, the newest version of Groovy the better. Usually there are more bugs fixed than new introduced ;). Some people just add Spock and have Groovy as a transitive dependency. Therefore, having that PR merged one day, I would also prefer 3.0.L(atest) Nevertheless, it is rather more important to remember to do the dependency update right before the release. To keep them up-to-date. Btw, if there is a suspicion that Spock depends on some Groovy feature added/fixed in some particular (minor) Groovy version there could be extra regression tests added. However, as I use them in my Gradle plugins (for Gradle versions, not Groovy), I'm definitely not convinced that Spock needs the same approach. |
f7190a5
to
155ccb5
Compare
docs/extensions.adoc
Outdated
@@ -117,6 +117,7 @@ To make predicates easier to read and write, the following properties are availa | |||
* `env` A map of all environment variables | |||
* `os` Information about the operating system (see `spock.util.environment.OperatingSystem`) | |||
* `jvm` Information about the JVM (see `spock.util.environment.Jvm`) | |||
* `instance` The specification instance if instance fields, shared fields or instance methods are needed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should mention that instance will require the test to execute to that point, similar as with the data-driven variables.
@@ -108,7 +118,7 @@ public IterationCondition(Closure condition, T annotation) { | |||
|
|||
@Override | |||
public void intercept(IMethodInvocation invocation) throws Throwable { | |||
Object result = evaluateCondition(condition, invocation.getIteration().getDataVariables()); | |||
Object result = evaluateCondition(condition, invocation, invocation.getIteration().getDataVariables()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you pass the invocation
and not the invocation.getInstance()
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because it is done the same for RetryConditionContext
, so I thought I just follow the same pattern here.
But I can of course also change that if you prefer.
If you do, should I change it for both?
fixes #1177
This change is