junit5-docker icon indicating copy to clipboard operation
junit5-docker copied to clipboard

Support for meta-annotations

Open xyzxyzxyzxyzxyz opened this issue 7 years ago • 1 comments

Hi.

Great work here. All I found missing is that the Docker annotation cannot be "meta-present".

That is, I cannot create a custom annotation:

@Docker( ... )
public @interface IntegrationTest {}

@IntegrationTest
public class TestClass { ... }  

And the solution is really simple!

Instead of this in DockerExtension.java:

private Docker findDockerAnnotation(ExtensionContext extensionContext) {
        Class<?> testClass = extensionContext.getTestClass().get();
        return testClass.getAnnotation(Docker.class);
}

Just use JUnit 5's AnnotationUtils class:

    private Docker findDockerAnnotation(ExtensionContext extensionContext) {
        Class<?> testClass = extensionContext.getTestClass().get();
        return AnnotationUtils.findAnnotation(testClass, Docker.class).orElse(null);
    }

xyzxyzxyzxyzxyz avatar May 29 '18 20:05 xyzxyzxyzxyzxyz

Hi,

That's a great idea ! Maybe throwing an exception instead of null would be better ? What about a PR ? This contribution worth having your name attached to it IMHO !

FaustXVI avatar Jun 25 '18 12:06 FaustXVI