mercredi 15 novembre 2017

How to retrieve method level annotation details

I'm trying to retrieve list of annotation in method level. And created below annotation interface.

    @Retention(RetentionPolicy.RUNTIME)
    @Target({ ElementType.METHOD }) 
    public @interface DataPublish 
    {
       String testName() default "";

    }

Used the annotation in below method:

public class TestCase1 {

    @DataPublish(testName = "This is test name")
    public static void test1() throws Exception {
     try {
         Assert.assertTrue(true);
         } catch (Exception ex) {
            ex.printStackTrace();
        }
      }
 }

I want to get the Field of method level annotation, and wanna change it at runtime.





Aucun commentaire:

Enregistrer un commentaire