Sunday, 28 September 2014

DDF CSV - Version 4.0

DDF 3.x version has only support for TestNG, with the DDF 4.0 version you can use DataDrivenFramework with out using TestNG API.

Current implementation of DataDrivenFramework can be integrated with any automation tool/api which supports java (ex: Java Webdriver, Openscript, etc). It can also be used as part of application development for reading the data from CSV file.

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)

2. Download the  "DDF Version - 4.0.zip" from repository.
3. Extract the "DDF Version - 4.0.zip" (zip file contains example programs and jar file).
4. 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:

Sample Program:
package examples.Non_TestNG_test.csv;

import java.io.File;
import java.util.List;
import java.util.Map;

import automation_home.ddf.wrapper.Wrapper;
import automation_home.ddf.constants.CsvConstants;
import automation_home.ddf.wrapperimpl.CsvWrapper;

public class TestData {

/**
* @param args
* @throws Exception
*/
public static void main(String[] args) throws Exception {
for (Map<String, String> h : configure()) {
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("----------------------------------------");
}
}

public static List<Map<String, String>> configure() throws Exception {
Wrapper wrapper = new CsvWrapper();

wrapper.setParameter(CsvConstants.FILE_PATH,
new File("").getAbsolutePath()
+ "\\src\\examples\\Non_TestNG_test\\csv\\TestData.csv");

wrapper.setParameter(CsvConstants.INCLUDE_TESTDATA_HEADER_NAME,
"includeTestData");
wrapper.setParameter(CsvConstants.INCLUDE_TESTDATA_YES, "TRUE");
wrapper.setParameter(CsvConstants.INCLUDE_TESTDATA_NO, "FALSE");

List<Map<String, String>> list = wrapper.retrieveData();
return list;
}
}

Output:

Watch Demo

<< Previous

No comments:

Post a Comment