Skip to content

Do not evaluate feature-skipping conditions for skipped specs #1459

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

Merged
merged 8 commits into from
May 21, 2022

Conversation

kriegaex
Copy link
Contributor

@kriegaex kriegaex commented Apr 12, 2022

The new spec MixedSpecSkippingExtensions verifies that this works correctly for both inherited and non-inherited versions of @Requires, @IgnoreIf and - not to forget - @Ignore. Because the two feature methods verify combinations of annotation types, they did not fit into any of the existing specs focused on single annotation-driven extensions. A separate spec makes more sense. It verifies both the new feature as such and interoperability between spec-ignoring extension types.

Fixes #1458.


In an additional commit, I raised the bar a bit, also verifying that feature-skipping annotation conditions are not evaluated in skipped parent classes of the bottom spec, up to the actually annotated, skipped spec.

Before this change, the spec-skipping extensions applied a premature optimisation I was skeptical of before: to only mark the bottom spec as skipped for an inherited annotation, instead of marking everything down to the bottom spec, starting with the annotated spec. This is the proper way to do it, if we are talking about inheritance.

In order to achieve this more easily, I added new utility methods SpecInfo.getSpecsToBottom() and SpecInfo.getSpecsToTop(). The latter is unused at the moment, but might come in handy in the future.

Verify that the feature also works for hierarchies of more than 2
classes, i.e. there are other classes in between annotated spec and
bottom spec.

Also verify that it still works correctly if the parent specs are
non-abstract, i.e. that they are ignored correctly not because
of being abstract but because of the corresponding annotation.

The parent classes also have their own feature methods now, so we can do
a more sophisticated count of executed/skipped features and containers.
@codecov
Copy link

codecov bot commented Apr 12, 2022

Codecov Report

Merging #1459 (a889e56) into master (ca264bd) will increase coverage by 79.59%.
The diff coverage is 92.85%.

@@              Coverage Diff              @@
##             master    #1459       +/-   ##
=============================================
+ Coverage          0   79.59%   +79.59%     
- Complexity        0     4015     +4015     
=============================================
  Files             0      404      +404     
  Lines             0    12565    +12565     
  Branches          0     1640     +1640     
=============================================
+ Hits              0    10001    +10001     
- Misses            0     1969     +1969     
- Partials          0      595      +595     
Impacted Files Coverage Δ
...ork/runtime/extension/builtin/IgnoreExtension.java 83.33% <50.00%> (ø)
...untime/extension/builtin/ConditionalExtension.java 82.19% <100.00%> (ø)
...k/runtime/extension/builtin/IgnoreIfExtension.java 100.00% <100.00%> (ø)
...k/runtime/extension/builtin/RequiresExtension.java 100.00% <100.00%> (ø)
...ava/org/spockframework/runtime/model/SpecInfo.java 90.41% <100.00%> (ø)
...java/org/spockframework/util/WrappedException.java 0.00% <0.00%> (ø)
...kframework/runtime/condition/EditPathRenderer.java 94.28% <0.00%> (ø)
...mework/runtime/extension/builtin/SeeExtension.java 100.00% <0.00%> (ø)
.../src/main/java/org/spockframework/util/Assert.java 54.54% <0.00%> (ø)
...rc/main/java/org/spockframework/util/TextUtil.java 58.02% <0.00%> (ø)
... and 399 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ca264bd...a889e56. Read the comment docs.

The new spec MixedSpecSkippingExtensions verifies that this works
correctly for both inherited and non-inherited versions of @requires,
@IgnoreIf and - not to forget - @ignore. Because the two feature methods
verify combinations of annotations, they did not fit into any of the
existing specs focused on single annotation-driven extensions. A
separate spec makes more sense. It verifies both the new feature as such
and interoperability between spec-ignoring extension types.

Fixes spockframework#1458.
Raise the bar in MixedSpecSkippingExtensions, also verifying that
feature-skipping annotation conditions are not evaluated in skipped
parent classes of the bottom spec, up to the actually annotated, skipped
spec.

Before this change, the spec-skipping extensions applied a premature
optimisation I was skeptical of before: to only mark the bottom spec as
skipped for an inherited annotation, instead of marking everything down
to the bottom spec, starting with the annotated spec. This is the proper
way to do it, if we are talking about inheritance.

In order to achieve this more easily, I added new utility methods
'SpecInfo.getSpecsToBottom()' and 'SpecInfo.getSpecsToTop()'. The latter
is unused at the moment, but might come in handy in the future.

Fixes spockframework#1458 (really, this time).
This both helps to better understand what they do and also provides a
bit more code coverage.
This has implications for the number of started, skipped, succeeding and
failing tests and containers. We want to make sure the numbers are
reported correctly, looking up the inheritance hierarchy, not just down.
This helps to spot possible regressions where accidentally not just sub
specs, but also or instead super specs would be skipped.
Copy link
Member

@leonard84 leonard84 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR this is going to be a valuable improvement.

The others follow later, if applicable.

Co-authored-by: Leonard Brünings <lord_damokles@gmx.net>
leonard84 added 2 commits May 21, 2022 10:17
* master:
  Bump org.gradle.test-retry from 1.3.2 to 1.4.0
  Make EnableSharedInjection public (spockframework#1472)
  Remove runtime dependency on Jetbrains Annotations (spockframework#1468)
  Add Dependabot configuration
  Use static imports for well known methods of Collections and Arrays
  Refactor SpecInfo extract shared logic into collectSpecHierarchy
  Discard unnecessary state in ConfineMetaClassChangesInterceptor (spockframework#1460)
  Update Groovy to 4.0.2
  Update Gradle plugins
  Update Gradle to 7.4.2
@leonard84 leonard84 enabled auto-merge (squash) May 21, 2022 08:51
@leonard84 leonard84 merged commit 79c8e96 into spockframework:master May 21, 2022
@leonard84
Copy link
Member

Thanks @kriegaex

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

Successfully merging this pull request may close these issues.

Do not evaluate IgnoreIf/Requires condition on method level, if whole spec is ignored
2 participants