vendredi 21 juillet 2017

Finding annotated methods in application code from maven integration test

I have a custom annotation in my program that I apply to methods. I would like to find all methods with a particular annotation. From my application code, I can use the Reflections package to do so:

new Reflections(
    new ConfigurationBuilder().setUrls(
        ClasspathHelper.forPackage("com.my.package")
    ).setScanners(new MethodAnnotationsScanner())
    ).getMethodsAnnotatedWith(MyAnnotation.class);

However, when I try to do the same from an integration test invoked via failsafe, no methods are found. How can I get my annotated methods from an integration test?





Aucun commentaire:

Enregistrer un commentaire