lundi 29 octobre 2018

java annotation putting them in method parameter like TestNG

I was wondering is there a way to pass my data from annotation to method parameter? Lets say yellow -> color for each test case. With reflection we can only get the information but not inject it. Let me know if you find similar post since the ones I found were different.

   //TestNG annotation
 @DataProvider(name = "provider")
public static Object[][] createData() {
    return new Object[][] {
            { "english", "test1" },
            { "english", "test2" },
            { "french", "test1" },
            { "french", "test2" },
    };
}

@Test(dataProvider = "provider")
@CustomAnnotation(source = "yellow")
public void test1(String language, String code, String color) {
    System.out.println(language + " " + code + color);
}





Aucun commentaire:

Enregistrer un commentaire