首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >有没有办法在TestNG报告摘要中显示我的DataProvider值?

有没有办法在TestNG报告摘要中显示我的DataProvider值?
EN

Stack Overflow用户
提问于 2019-06-26 23:48:21
回答 2查看 1K关注 0票数 1

基本上,我在多个配置上的LambdaTest Selenium网格上运行我的自动化测试。我在testng测试套件中添加了7个测试类文件。我已经在DataProvider类中通过了浏览器、浏览器版本、操作系统和分辨率等配置。每个测试将在DataProvider类中传递的所有配置上运行。但是,我无法在testng emailable-report的摘要部分中获得这些配置值。

我想要的是DataProvider类文件-- testng emailable-report的摘要部分中的配置值,它将帮助我获得每个测试通过或失败的配置。

到目前为止,我的testng报告看起来像这样:https://ibb.co/5TbDdGw

在顶部,它显示了在7个不同的类文件中添加的7个测试用例。

代码语言:javascript
运行
复制
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值的报告。

EN

回答 2

Stack Overflow用户

发布于 2019-06-28 18:07:10

您可以将它们添加到测试的描述中。

代码语言:javascript
运行
复制
@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);
}
票数 0
EN

Stack Overflow用户

发布于 2019-09-02 16:51:37

我已经针对文章编写的代码测试了您的dataProvider,您在该文章中发布了您的评论- https://www.swtestacademy.com/change-test-name-testng-dataprovider/

我得到了下面的结果-

代码语言:javascript
运行
复制
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")

  • I已更改为BeforeMethod中的testData1,以便在testName中打印浏览器版本,还将测试中的参数从1增加到4。
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56776684

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档