Parameter for dataprovider from tesng.xml

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Parameter for dataprovider from tesng.xml

praveen133t
Say I have a parameter in testng.xml as below

<parameter name="env" value="test1" />

So I want this parameter to be accessed in my dataprovider as below

@DataProvider
@Parameters(value = { "env" } )
public object[][] getData(String envmt) {

....
Use the env parameter for manipulation and return a completely
......


}

@Test(dataprovider = "getdata")
public void runTest(String something) {

...My test

}

Is this possible? I tried but getting some errors. All I want to do is use parameter in the testng.xml in my dataprovider. 

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Reply | Threaded
Open this post in threaded view
|

Re: Parameter for dataprovider from tesng.xml

praveen133t
ok. I got it done. I used 

String inputFile = context.getCurrentXmlTest().getParameter("filePath");

I then referenced my testdata file path as a parameter in testng.xml and it worked fine.



On Saturday, August 3, 2013 4:07:18 PM UTC-5, talon wrote:
Say I have a parameter in testng.xml as below

<parameter name="env" value="test1" />

So I want this parameter to be accessed in my dataprovider as below

@DataProvider
@Parameters(value = { "env" } )
public object[][] getData(String envmt) {

....
Use the env parameter for manipulation and return a completely
......


}

@Test(dataprovider = "getdata")
public void runTest(String something) {

...My test

}

Is this possible? I tried but getting some errors. All I want to do is use parameter in the testng.xml in my dataprovider. 

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/groups/opt_out.