我已使用Dataprovider传递测试值,并且希望这些值显示在testNG范围报告中。我有七个测试用例,这些测试用例在DataProvider中传递的多个测试值上运行。通过单击范围报告中的方法名称,我希望该报告显示已对测试执行了哪些值。`
这是我的数据提供程序类:
public class MyDataProvider {
@DataProvider
public Object[][] realTimeConfiguration() {
return new Object[][] {
new Object[] {"safari", "safari5.1","macoslion" },
new Object[] { "chrome", "chrome76", "win10", "1280x1024" },
new Object[] {"chrome", "chrome75","win10","1280x1024" },
new Object[] {"chrome", "chrome74","win10","1280x1024" },
new Object[] {"chrome", "chrome73","win10","1280x1024" },
new Object[] {"chrome", "chrome72","win10","1280x1024" },
new Object[] {"firefox", "firefox68","win10","1280x1024" },
new Object[] {"firefox", "firefox67","win10","1280x1024" },
new Object[] {"firefox", "firefox66","win10","1280x1024" },
new Object[] {"firefox", "firefox65","win10","1280x1024" },
new Object[] {"firefox", "firefox64","win10","1280x1024" },
};
}
}
谢谢!
答案 0 :(得分:0)
您可以考虑通过基类方法手动记录值-例如
public class MyTest extends BaseTest {
@Test(dataProvider = "realTimeConfiguration", dataProviderClass = MyDataProvider.class)
public void verifySomething(String browser, String userAgent, String platform, String resolution) {
logToReport(String.format("Test started for: Browser: '%s', userAgent: '%s', platform: '%s', resolution: '%s'"));
}
}