This project exercises testng dataProviders
- Excel 2003 OLE documents - Horrible SpreadSheet Format org.apache.poi.hssf.usermodel.*)
- Excel 2007 OOXML (.xlsx) - XML SpreadSheet Format org.apache.poi.xssf.usermodel.*
- OpenOffice SpreadSheet (.ods) example1 ,[example 2]http://half-wit4u.blogspot.com/2011/05/read-openoffice-spreadsheet-ods.html
- Custom JSON org.json.JSON
- csv testnt csv file
- fillo fillo
For example test case performs Selenium link count test with the data providers of the following supported data types:
- Excel 2003
- Excel 2007
- Open Office Spreadsheet
- JSON
The test inputs are defined as table with colums
| ROWNUM | SEARCH | COUNT |
|---|---|---|
| 1 | junit | 100 |
which are the test ID, the seach term and expected minimum count of articles found on the forum by the title search.
The following annotations are provided to the test methods:
@Test(enabled = true, singleThreaded = false, threadPoolSize = 1, invocationCount = 1, description = "searches publications for a keyword", dataProvider = "Excel 2003")
@DataFileParameters(name = "data_2003.xls", path = "${USERPROFILE}\\Desktop", sheetName = "Employee Data")
public void test_with_Excel_2003(double rowNum, String search_keyword,
double expected_count) throws InterruptedException {
parseSearchResult(search_keyword, expected_count);
}or
@Test(enabled = true, singleThreaded = false, threadPoolSize = 1, invocationCount = 1, description = "searches publications for a keyword", dataProvider = "Excel 2007")
@DataFileParameters(name = "data_2007.xlsx", path = ".")
public void test_with_Excel_2007(double rowNum, String search_keyword,
double expected_count) throws InterruptedException {
parseSearchResult(search_keyword, expected_count);
}or
@Test(enabled = true, singleThreaded = false, threadPoolSize = 1, invocationCount = 1, description = "searches publications for a keyword", dataProvider = "OpenOffice Spreadsheet")
@DataFileParameters(name = "data.ods", path = ".")
public void test_with_OpenOffice_Spreadsheet(double rowNum,
String search_keyword, double expected_count)
throws InterruptedException {
parseSearchResult(search_keyword, expected_count);
}or
@Test(enabled = true, singleThreaded = false, threadPoolSize = 1, invocationCount = 1, description = "searches publications for a keyword", dataProvider = "JSON")
@DataFileParameters(name = "data.json", path = "")
public void test_with_JSON(String search_keyword, double expected_count)
throws InterruptedException {
parseSearchResult(search_keyword, expected_count);
}The data provider class would load all columns from Excel 2003, Excel 2007 or OpenOffice spreadsheet respectively and run test method with every row of data. It is up to the test developer to make the test method consume the correct number and type or parameters as there are columns in the spreadsheet.
- MySQL testng dataprovider
- xml testng DataProviders
- javarticles.com
- testng-users forum
- passing parameters to provider via Method
- JUnitParams - TestNg-style
JUnitParamsRunnerandParametersProviderclasses. - testng samples
- barancev/testng_samples
- ahussan/DataDriven
- poi ppt
- paypal/SeLion data providers
- RestAPIFramework-TestNG/.../ExcelLibrary
- GladsonAntony/WebAutomation_Allure ExcelUtils.java
- sskorol/tesst-data-supplier
- converting gradle to pom
- using gradle maven plugin to produce pom.xml
Status: pending