lundi 19 octobre 2015

How to process all the features of an annotation through JAVA Reflection

I knew we can execute the class based on the annotation through java reflection as below:

Method[] method = className.getMethods();

for (Method me : method) {
    if (me.isAnnotationPresent(org.testng.annotations.Test.class)) {  
        Method getMethods = Class.forName(format).getDeclaredMethod(me.getName());  
        String executeMethods=(String)getMethods.invoke(currentClassFile);  
    }
}

The above code will execute a methods which is annotated with @Test(TestNG framework). Is it possible to process the features which are available with that annotation. Like (priority, dependsOnMethods, dependsOnGroup,(those are values of @Test annotation example @Test(priority=1), @Test(dependsOnMethod="Test1") etc.,) and so on.,)?

If possible, How to implement the things?





Aucun commentaire:

Enregistrer un commentaire