spockframework / spockframework/spock

Allow @IgnoreIf to be used as meta-annotation

Open
#1,558 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

new feature
Dominant language
Java
Stars
3.6k
Forks
483
PR merge metrics
No merged PRs in 30d

Description

Is your feature request related to a problem?

We have many long-running integration tests annotated with custom @IntegrationSpec, that are not to be run as part of the standard build.
Hence, we want to exclude the long-running tests if a slow-test system property is defined.

The annotation looks like this:

@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@DataJpaTest
@AutoConfigureEmbeddedDatabase
@IgnoreIf(value = { System.getProperty("slow-test") != "true" })
@interface IntegrationSpec {}

When using the @IgnoreIf as a meta-annotation the way above, it is ignored by Spock.

Describe the solution you'd like

The @ignoreIf annotation allows inheritance. However, it would be cleaner if the @ignoreIf could be used as a meta-annotation so that the tests can extend Specification rather than a custom implementation, that would exist only because of the need for @IgnoreIf being applied to it.

Describe alternatives you've considered

At the moment, we use Groovy @AnnotationCollector to work around the problem. However, IntelliJ has got issues whenever recompiling the code.

Additional context

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No files or tests are named in the issue. Start by reproducing the shown @IntegrationSpec example and tracing how Spock handles @IgnoreIf and meta-annotations; done means @IgnoreIf works through the custom annotation while specifications can still extend Specification.

Written by the indexing model from the issue text.

Assessment

Tech stack
groovy, java
Domain
testing
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.