Test Data for multiple test cases be maintained in single excel sheet, can be used for small projects having few test cases/modules with less test data. Easy to maintain and update test data since all the test data resides in single excel sheet.
Issue in 4.0:
DDF 4.0 supports maintaining test data for multiple test cases in a single excel sheet, but as the test data increases or decreases, test data configuration settings should be updated each time in the prog.
Issue in 4.0:
DDF 4.0 supports maintaining test data for multiple test cases in a single excel sheet, but as the test data increases or decreases, test data configuration settings should be updated each time in the prog.
Enhancement in 4.1:
In version 4.1 supports maintaining test data for multiple test cases in a single excel sheet, as the test data increases or decreases no need to update any configuration settings in the program, DDF will take care of the changes.
For information on other DDF versions click link DataDrivenFramework.
1. Prerequisite:
i. Java 1.6
ii. Eclipse IDE or any other Java IDE (ex: NetBeans IDE)
iii. Set POI API jar files in java build path.
iv. TestNG plugin should be configured in Eclipse IDE.
v. TestNG jar file in java build path.
Download Apache POI, follow below process
1. Goto url: http://poi.apache.org/
2. Click on "download" link (i.e. http://poi.apache.org/download.html page opens)
3. Click on "poi-bin-<<version>>.zip" link
4. Select the mirror and download the "poi-<<version>>.zip"
5. Extract the downloaded "poi-<<version>>.zip" file, next step is to set the java build path.
Files required in java build path.
1. poi-<<version>>.jar
2. poi-ooxml-<<version>>.jar
3. poi-ooxml-schemas-<<version>>.jar
Open the "ooxml-lib" folder present in the extracted "poi-<<version>>.zip" file, set the below jar files in java build path.
4. dom4j-<<version>>.jar
5. xmlbeans-<<version>>.jar
7. Extract the "DDF Version - 4.0.zip" (zip file contains example programs and jar file).
8. Set "AH-DDF-4.0.jar" in java build path.
Note:
'AH-DDF-<<Version>>.jar' is proprietary jar file, distributed for free.
Java Build Path:
Test Data:
package examples.TestNG_test.excel;
import java.io.File;
import java.util.HashMap;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import automation_home.ddf.constants.ExcelConstants;
import automation_home.ddf.wrapper.Wrapper;
import automation_home.ddf.wrapperimpl.ExcelWrapper;
public class CustomPosition2_TestData{
@DataProvider
public Object[][] dp1() throws Exception {
Wrapper wrapper = new ExcelWrapper();
wrapper.setParameter(ExcelConstants.FILE_PATH, new File("").getAbsolutePath()+"\\src\\examples\\TestNG_test\\excel\\CustomPosition_2.xls");
wrapper.setParameter(ExcelConstants.SHEET_NAME, "FlightInfo");
wrapper.setParameter(ExcelConstants.TESTCASE_NAME, "TestCase1");
wrapper.setParameter(ExcelConstants.TESTCASE_START_ELEMENT, "_Start");
wrapper.setParameter(ExcelConstants.TESTCASE_END_ELEMENT, "_End");
wrapper.setParameter(ExcelConstants.INCLUDE_TESTDATA_HEADER_NAME, "Execution");
wrapper.setParameter(ExcelConstants.INCLUDE_TESTDATA_YES,"RUN");
wrapper.setParameter(ExcelConstants.INCLUDE_TESTDATA_NO,"NO-RUN");
return wrapper.retrieveTestData();
}
@Test(dataProvider="dp1", enabled=true)
public void test1(HashMap<String, String> h){
System.out.println("FlightName : "+h.get("FlightName"));
System.out.println("FlightNumber : "+h.get("FlightNumber"));
System.out.println("AirPort : "+h.get("AirPort"));
System.out.println("Date : "+h.get("Date"));
System.out.println("---------------------------------");
}
}
Output:
Click the link 'Watch Demo'.
No comments:
Post a Comment