简体   繁体   English

如何在testng扩展区报告版本2.41.2(相关代码)中添加数据提供者值

[英]How to add data provider values in testng extent-report version 2.41.2(relevantcodes)

I have used Dataprovider to pass my test values and I want these values to get displayed in my testNG extent report. 我已使用Dataprovider传递测试值,并且希望这些值显示在testNG范围报告中。 I have seven test cases and these test cases run on multiple test values passed in DataProvider. 我有七个测试用例,这些测试用例在DataProvider中传递的多个测试值上运行。 By clicking on the method name in extent report, I want the report to display that on which values the test has been executed.` 通过单击范围报告中的方法名称,我希望该报告显示已执行测试的值。

Here is my dataprovider class: 这是我的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" },

        };

    }
}

Thanks in advance !! 提前致谢 !!

You can consider logging the values manually through a base class method - for example 您可以考虑通过基类方法手动记录值-例如

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'"));
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM