mardi 29 mai 2018

Custom Annotation not found while unit testing

say i've an Annotation like that:

@Retention(RetentionPolicy.RUNTIME)
public @interface AutoConvert {
    boolean enabled() default true;
}

and class annotated with it:

@AutoConvert
public class ExampleCommandToExample extends BaseConverter{}

On the superclass i'am doing the following:

Annotation annotation = (AutoConvert) this.getClass().getAnnotation(AutoConvert.class);

Everything works fine on runtime!

But! While unit testing it with JUnit: getAnnotation(AutoConvert.class) always returns null.

Has anyone an answer for me? I would really appreciate it.

Thank you in advance.





Aucun commentaire:

Enregistrer un commentaire