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

Support meta-annotations for includeAnnotationClasses & excludeAnnotationClasses #95

Open
mjustin opened this issue Feb 11, 2021 · 0 comments
Labels
enhancement New feature or request

Comments

@mjustin
Copy link

mjustin commented Feb 11, 2021

It would be nice if includeAnnotationClasses & excludeAnnotationClasses supported meta-annotations.

Meta-annotations are handy when creating a hierarchy of annotations, some of which are often but not always grouped together.

Example

Given the following classes in package com.example:

@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
public @interface Flaky {
}

@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Flaky
public @interface IntegrationTest {
}

@IntegrationTest
public void MyIntegrationTest {
    @Test
    public void testTheThing() {
    // ...
   }
}

And given the following Gradle config:

plugins {
    id 'org.gradle.test-retry' version "${testRetry.version}"
}

test {
    retry {
        maxRetries = 3
        filter {
            getIncludeAnnotationClasses.add("com.example.Flaky")
        }
    }
}

I would want MyIntegrationTest to be retried on failure, since its @IntegrationTest is annotated with @Flaky.

Additional notes

JUnit 5 annotations can be used as meta-annotations:

JUnit Jupiter annotations can be used as meta-annotations. That means that you can define your own composed annotation that will automatically inherit the semantics of its meta-annotations.

A number of other frameworks (e.g. Spring) support meta-annotations as well.

I don't believe JUnit 4 or TestNG has support for meta-annotations.

The Groovy language has built-in support for meta-annotations, which means that Spock already gets meta-annotations for free. Additionally, JUnit 4 and TestNG tests written in Groovy would also get meta-annotations for free.

@mjustin mjustin changed the title Support meta-annotations Support meta-annotations for includeAnnotationClasses & excludeAnnotationClasses Feb 11, 2021
@pshevche pshevche added the enhancement New feature or request label Apr 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants