junit5-docker
junit5-docker copied to clipboard
Support for meta-annotations
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);
}
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 !