基本上,我在 LambdaTest Selenium Grid 上的多种配置上运行自动化测试。我在 testng 测试套件中添加了 7 个测试类文件。我已经在我的 DataProvider 类中传递了浏览器、浏览器版本、操作系统和分辨率等配置。每个测试都将在 DataProvider
类中传递的所有配置上运行。但是,我无法在 testng emailable-report 的摘要部分中获取这些配置值。
我想要的是在 testng emailable-report 的摘要部分中有 DataProvider
类文件配置值,这将帮助我了解每个测试通过或失败的配置。
到目前为止,我的 testng 报告如下所示:https://ibb.co/5TbDdGw
顶部显示了 7 个不同类文件中添加的 7 个测试用例。
package com.mydataprovider;
import org.testng.annotations.DataProvider;
public class MyDataProvider {
@DataProvider
public Object[][] realTimeConfiguration() {
return new Object[][] {
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" },
};
}
}
这是我的 DataProvider
类,其中包含配置。
在共享的报告屏幕截图中,它显示所有测试方法都在 DataProvider
中提到的所有 10 个配置上运行。但是,它没有在报告摘要中显示我的每个测试运行的配置。
请帮助生成一份报告,其中在 testng 报告摘要中包含 DataProvider
值。
最佳答案
您可以将它们添加到测试的描述中。
@Test(dataProviderClass = DataProviderClass.class, dataProvider = "dataProviderMethod")
public void testMethod(String param1, String param2, String param3, String param4) {
ITestResult result = Reporter.getCurrentTestResult();
result.getMethod().setDescription(param1 + " " + param2 + " " + param3 + " " + param4);
}
关于java - 有没有办法在 TestNG 报告摘要中显示我的 DataProvider 值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56776684/