Use Java Annotation With JUnit 5 Extension
Java annotations are quite useful in many areas such as introspection, Aspect-Oriented Programming, etc. Spring Framework uses quite a lot of annotations. My team has been using annotations extensively in our projects and one particular use case is using annotations together with JUnit 5 ParameterResolver to inject test resources. We will start by creating a custom annotation: @Target(ElementType.PARAMETER) @Retention(RetentionPolicy.RUNTIME) @Documented public @interface FileResource { /** * @return the path to the resource. */ String value(); /** * @return the type of value that should be decoded from the resource */ Class<?> type() default String.class; } Then we would need to…