aspose file tools*
The moose likes Testing and the fly likes How to have different data provides in TestNG Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Engineering » Testing
Bookmark "How to have different data provides in TestNG" Watch "How to have different data provides in TestNG" New topic
Author

How to have different data provides in TestNG

Gopi Chella
Ranch Hand

Joined: Apr 26, 2010
Posts: 53
In TestNG i am using Data provider to test my testXSLExtractor method with large number of data(Data driven testing), here how can i have more than one data provider to my test method(testXSLExtractor)? is it possible with TestNG ?

something like this dataProvider = "UrlProvider1,UrlProvider2,UrlProvider3"(i tried this way but no luck).



SCJP 1.5
Gopi Chella
Ranch Hand

Joined: Apr 26, 2010
Posts: 53
OOPS !!! No one replied
Tina Smith
Ranch Hand

Joined: Jul 21, 2011
Posts: 171
    
    5

Maybe you should try using google.
"different data providers in testng" gives some good results on the first page.

I skimmed the one from "Old Nabble"...


Everything is theoretically impossible, until it is done. ~Robert A. Heinlein
s lekkala
Greenhorn

Joined: Jul 25, 2011
Posts: 14
Recently i have worked on that, so find the below code to understand the solution..

The below code used to read the data from excel sheet and returns the array.

@DataProvider(name = "PegaDataPool")
public Object[][] createDataPool(Method testMethods) {
ExcelReader readExcel = new ExcelReader();
List<String> tableName = new LinkedList();
if (testMethods.getName().equalsIgnoreCase("testNewCaseRegistration")) {
tableName.add("pegaUserData");
Object[][] retObjArr = readExcel.getTableArray("C:/workspace/VTAF-4.0/src/TestData/PegaTestData.xls","Pega User", tableName);
return (retObjArr);
}
return null;
}

you can use above values in the below methods

@Test(dataProvider = "PegaDataPool")
public void testNewCaseRegistration(String branch, String enquiryAmount,String debitAmount, String transactionDate, String tableName)throws Exception {

these branch, enquiryAmount variables can use whenever you require the data present in it.

}

Please find the attachment to know the data present in excel sheet.


Hope it will be useful to u...


Gopi Chella
Ranch Hand

Joined: Apr 26, 2010
Posts: 53
Hi,

Thanks for your reply, however my question is different.
For example you have three data provider methods like below

the above are three seperate data provider method and my requirement is i want to use all the three data provider in my Test method like below,



Cedric Beust
author
Ranch Hand

Joined: Oct 12, 2004
Posts: 46
No, but nothing stops you from having a data provider combine the results of several data providers and use that one in your @Test method.

Gopi Chella
Ranch Hand

Joined: Apr 26, 2010
Posts: 53
Thanks i got it .
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to have different data provides in TestNG
 
Similar Threads
Unable to run DataSource related testcases in TestNG with command prompt
Dataprovider in TestNg
most important feature in TestNG
How does surefire work
What is the concept of TestNG @DataProvider?