0

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 :(

Swapnil Kotwal
  • 5,418
  • 6
  • 48
  • 92

1 Answers1

2

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();
juherr
  • 5,640
  • 1
  • 21
  • 63
  • can you please help me to get equivalent packages for old jar `import org.testng.IInvokedMethod`, `import org.testng.collections.Lists;` – Swapnil Kotwal May 10 '16 at 11:21
  • It looks `IInvokedMethod` didn't exist in 5.5 and you are not supposed to need `Lists`. But for your information both classes are available in 5.11 (the latest 5.x-jdk5 version which, with luck, will be more acceptable for your management). – juherr May 10 '16 at 11:29
  • Another solution will be to fork TestNG but 5.5 is sooo old than there is no tag in the official SCM (first tag is 5.11) – juherr May 10 '16 at 11:31