问题
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