java批注将它们放在方法参数(如TestNG)中

时间:2018-10-30 01:24:54

标签: java reflection testng

我想知道是否有一种方法可以将我的数据从注释传递到方法参数?假设每个测试案例的颜色为黄色->颜色。通过反射,我们只能获取信息,而不能注入信息。让我知道您是否找到相似的帖子,因为我发现的帖子不同。

   //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);
}

0 个答案:

没有答案