Is it possible for a TestNG DataProvider to read test data from the testng.xml config file? Or is this unrealistic for some reason? I would like to be able to read test data from that file at the suite level and class level.
So, given a testing.xml file like this (which I am unsure is realistic or not), how would I do this? I have written a DataProvider using XStream (or Jackson) before and so I am well versed in my own custom .xml format, but sticking to the strict format of the testing.xml is where I am worried about this.
The following testing.xml is obvious invalid but I am just trying to show the kind of thing I would like to do:
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="TestAll">
<parameter name="hubUrl" value="http://localhost:4444/wd/hub"/>
<parameter name="reportFile" value="CustomReport.html"/>
<test name="etsy">
<parameter name="reportFile" value="CustomReport.html"/>
<classes>
<class name="qa.examples.suite.TestSearch">
<parameter name="appUrl" value="http://etsy.com" type="java.lang.String"/>
<parameter name="browser" value="Firefox" type="java.lang.String"/>
<parameter name="testEnabled" value="true" type="java.lang.Boolean"/>
<methods>
<include name="testEtsySearch"/>
<tests>
<test>
<parameter name="testNum" value="1" type="java.lang.Integer"/>
<parameter name="searchTerm" value="cell phone" type="java.lang.String"/>
<parameter name="searchTerm" value="batteries" type="java.lang.String"/>
</test>
<test>
<parameter name="testNum" value="2" type="java.lang.Integer"/>
<parameter name="searchTerm" value="buttons" type="java.lang.String"/>
<parameter name="searchTerm" value="metal" type="java.lang.String"/>
</test>
</tests>
</include>
</methods>
</class>
<class name="qa.examples.suite.TestFilters" />
</classes>
</test>
</suite>
So, is something like this possible? If so, how would you do it?