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
Test the interceptor lifecycle #1668
Conversation
33ad084
to
f7055ec
Compare
e4775ce
to
93f8262
Compare
f7055ec
to
aa845e5
Compare
93f8262
to
8569665
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1668 +/- ##
============================================
- Coverage 80.43% 80.39% -0.04%
+ Complexity 4234 4233 -1
============================================
Files 434 434
Lines 13279 13279
Branches 1688 1688
============================================
- Hits 10681 10676 -5
- Misses 1960 1964 +4
- Partials 638 639 +1 ☔ View full report in Codecov by Sentry. |
8569665
to
8fae8fd
Compare
aa845e5
to
0c0366a
Compare
e364ba0
to
117cd26
Compare
...rces/org/spockframework/smoke/Interceptors__interceptors_are_called_in_the_correct_order.txt
Outdated
Show resolved
Hide resolved
71411ac
to
0787f97
Compare
3c3183a
to
42445ff
Compare
0787f97
to
e4a89fe
Compare
42445ff
to
992ad9d
Compare
e4a89fe
to
f5c7ac0
Compare
992ad9d
to
ccc6ebb
Compare
f5c7ac0
to
b2abb60
Compare
ccc6ebb
to
1c49943
Compare
b2abb60
to
810fccc
Compare
setup start (SubSpec.foo[#0]) | ||
setup start (SubSpec.foo[#0]) | ||
setup end (SubSpec.foo[#0]) | ||
setup end (SubSpec.foo[#0]) |
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.
🤔 From a reporting POV it isn't ideal that you get the same spec name twice here, as one of the invoked methods is from the SuperSpec, although it is correct that the the feature belongs to the SubSpec
. The same applied to the other methods.
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.
I agree, but that is nothing I change here.
I just add a test that verifies the current state, like I also do not fix the simple feature lifecycle here, but in a separate upstack PR.
So this simply is, what you get from IMethodInvocation#spec#name
currently.
Maybe it should generally be reviewed whether the delivered information makes sense in all cases.
But actually I don't see how "one of the invoked methods is from the SuperSpec" here.
The super spec does not have any setup method.
It is just the super specs "wrapper around all setup methods" that is called for the setup phase of the sub spec.
If you have setup
method in both sub spec and super spec like in the other feature, it looks like this:
setup start (SubSpec.subFeature1[#0])
setup start (SubSpec.subFeature1[#0])
setup method start (SuperSpec.subFeature1[#0].setup())
fixture method start (SuperSpec.subFeature1[#0].setup())
fixture method end (SuperSpec.subFeature1[#0].setup())
setup method end (SuperSpec.subFeature1[#0].setup())
setup end (SubSpec.subFeature1[#0])
setup method start (SubSpec.subFeature1[#0].setup())
fixture method start (SubSpec.subFeature1[#0].setup())
fixture method end (SubSpec.subFeature1[#0].setup())
setup method end (SubSpec.subFeature1[#0].setup())
setup end (SubSpec.subFeature1[#0])
But it might also be questionable whether this is correct.
Should it really say the spec is super, which matches the actual method called,
but the feature is the one from the sub spec which does not match the feature?
Maybe it would make more sense if spec here is indeed the sub spec, matching the feature you get, and if you want to know from where the method is from, you use method.parent
?
I'm not sure how it best should be to be honest. For "shared initializer" for example, you get sub and super, not twice sub like 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.
Or maybe it makes sense that for the actual "...method" one the IMethodInvocation.spec
gives the one matching that method as it is the main target in view currently, and if you want the features spec, you use feature.parent
.
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.
Actually, in my other upstack PR I add tests for whether the fields are set at all or not,
but they don't verify to what they are set and whether the spec is consistent with the feature and so on. I guess another PR could introduce such checks later on and fix some of this if it is not like intended.
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.
I at least improved the reporting in the method-interceptor cases above now, so that the features are not attributed to the wrong specification.
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.
I was not saying that we should change anything on the IMethodInvocation side, but it would be possible to change
specInfo.specsBottomToTop*.addSetupInterceptor {
proceed(it, 'setup', "$it.spec.name.$it.feature.name[#$it.iteration.iterationIndex]")
}
to
specInfo.specsBottomToTop.each { spec -> spec.addSetupInterceptor {
proceed(it, 'setup', "$spec.name.$it.feature.name[#$it.iteration.iterationIndex]")
}
}
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.
I just add a test that verifies the current state, like I also do not fix the simple feature lifecycle here, but in a separate upstack PR.
So, the intention is to visualize which interceptors are called in what order. Given that the information in IMethodInvocation
is no always sufficient for this, I think it makes sense to change the interceptor registrations to include the spec, like I've shown above.
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.
Oh, now I got it, yeah, makes absolute sense. Fixed now.
810fccc
to
d9f1fee
Compare
d9f1fee
to
0d9ac66
Compare
0d9ac66
to
586f1c1
Compare
No description provided.