TestNG “getCurrentXmlTest()).getAllParameters()” API using very old testng-5.4-jdk15.jar TestNG library

时间秒杀一切 提交于 2019-12-12 03:28:02

问题


For some reason I have to use old TestNG library which doesn't have "getCurrentXmlTest()).getAllParameters()" API

How should I get all TestXML parameter using testng-5.4-jdk15.jar

For latest TestNG version, this is how we get all params but how can I simulate such a code using testng-5.4-jdk15.jar

@DataProvider(name = "DataFile")
public Object[][] testdata(ITestContext context) {
    Map<String, String> parameters = (((ITestContext)context).getCurrentXmlTest())
            .getAllParameters();
    return new Object[][] { { parameters } };
}

P.S. :- I can't upgrade jar :(


回答1:


From TestNG 5.5 sources (because 5.4 sources and binaries are not available on maven central), this following should work:

Map<String, String> parameters = (((TestRunner)context).getTest()).getParameters();


来源:https://stackoverflow.com/questions/37132322/testng-getcurrentxmltest-getallparameters-api-using-very-old-testng-5-4-j

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!