基本上,我在多个配置上的LambdaTest Selenium网格上运行我的自动化测试。我在testng测试套件中添加了7个测试类文件。我已经在DataProvider
类中通过了浏览器、浏览器版本、操作系统和分辨率等配置。每个测试将在DataProvider
类中传递的所有配置上运行。但是,我无法在testng emailable-report的摘要部分中获得这些配置值。
我想要的是DataProvider
类文件-- testng emailable-report的摘要部分中的配置值,它将帮助我获得每个测试通过或失败的配置。
到目前为止,我的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
值的报告。
发布于 2019-06-28 18:07:10
您可以将它们添加到测试的描述中。
@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);
}
发布于 2019-09-02 16:51:37
我已经针对文章编写的代码测试了您的dataProvider,您在该文章中发布了您的评论- https://www.swtestacademy.com/change-test-name-testng-dataprovider/
我得到了下面的结果-
PASSED: testRenaming_chrome76("chrome", "chrome76", "win10", "1280x1024")
PASSED: testRenaming_chrome75("chrome", "chrome75", "win10", "1280x1024")
PASSED: testRenaming_chrome74("chrome", "chrome74", "win10", "1280x1024")
PASSED: testRenaming_chrome73("chrome", "chrome73", "win10", "1280x1024")
PASSED: testRenaming_chrome72("chrome", "chrome72", "win10", "1280x1024")
PASSED: testRenaming_firefox68("firefox", "firefox68", "win10", "1280x1024")
PASSED: testRenaming_firefox67("firefox", "firefox67", "win10", "1280x1024")
PASSED: testRenaming_firefox66("firefox", "firefox66", "win10", "1280x1024")
PASSED: testRenaming_firefox65("firefox", "firefox65", "win10", "1280x1024")
PASSED: testRenaming_firefox64("firefox", "firefox64", "win10", "1280x1024")
https://stackoverflow.com/questions/56776684
复制相似问题