Wednesday 16 July 2014

DDF Workbook - Version 3.0.4

1. If you are new to the blog, watch below demo video's
        Click on the link DDF - Workbook Version-1.0 to watch the demo video.
        Click on the link DDF - Workbook Version-3.0.2  to watch the demo video.
2. Download the  "DDF Version - 3.0.4.zip" from repository.
3. Extract the "DDF Version - 3.0.4.zip"
4. Click the link for Prerequisite and Setup.

Note:
'AH-DDF-<<Version>>.jar' is proprietary jar file, distributed for free.

Issue in 3.0.3:
            It is mandatory to have initial position of test data in workbook should start from (Row = 0, Column = 0)  otherwise framework can't fetch the the test data from workbook.

Enhancement added in Version-3.0.4:
      In "Data Driven Framework - Workbook" version-3.0.4 initial position of the test data can be changed in workbook and same should be configured in the program.
> If you don't wish to change initial position of test data in workbook(i.e. 0,0) then no need of configuring initial position in test data, by default framework fetches the test data from workbook starting from position (0,0) in workbook.

> Set the "AH-DDF-3.0.4.jar" in java build path.

Initial position is configurable, refer below Figure-1.

   Figure 1

> Test data workbook file present in 'examples' folder at location "src\examples\test\excel\CustomIntialPosition.xls" 
> 'examples' folder is present in 'DDF Version - 3.0.4.zip' can be downloaded from repository

Note: You can perform the same operation (i.e. Initial position configuration) with ".xlsx" file also.

Program:
package examples.test.excel;
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 CustomIntialPosition_TestData{
 Wrapper wrapper = new ExcelWrapper();

  @DataProvider
  public Object[][] dp() throws Exception {
   wrapper.setParameter(ExcelConstants.FILE_PATH, "D:\\V_Drive\\SW Testing\\WDriver\\DDF Proj V-3.0.4\\src\\examples\\test\\excel\\CustomIntialPosition.xls");
   wrapper.setParameter(ExcelConstants.SHEET_NAME, "FlightInfo");

   /*wrapper.setParameter(ExcelConstants.INCLUDE_TESTDATA_HEADER_NAME, "Execution");
   wrapper.setParameter(ExcelConstants.INCLUDE_TESTDATA_YES,"RUN");
   wrapper.setParameter(ExcelConstants.INCLUDE_TESTDATA_NO,"NO-RUN");
         */
   wrapper.setParameter(ExcelConstants.INITIAL_POSITION, "4,1");
   return wrapper.retrieveTestData();
  }

  @Test(dataProvider="dp")
  public void test(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("----------------------------------------");
   }
}

Sample Program is present in 'examples' folder at location "src\examples\test\excel\CustomIntialPosition_TestData.java"
> 'examples' folder is present in 'DDF Version - 3.0.4.zip' can be downloaded from repository.

Output:
[TestNG] Running:
  C:\Users\pbeleda\AppData\Local\Temp\testng-eclipse--1415773696\testng-customsuite.xml

FlightName : KingFisher123
FlightNumber : 10010.0
AirPort : Hyderabad
Date : Sat Oct 04 00:00:00 IST 2014
----------------------------------------
FlightName : India Air Lines998
FlightNumber : 10011.0
AirPort : Bangalore
Date : Thu Apr 10 00:00:00 IST 2014
----------------------------------------
FlightName : Emirates332
FlightNumber : 10012.0
AirPort : Hyderabad
Date : Sun Jun 22 00:00:00 IST 2014
----------------------------------------
PASSED: test({Execution=RUN, AirPort=Hyderabad, FlightName=KingFisher123, Date=Sat Oct 04 00:00:00 IST 2014, FlightNumber=10010.0})
PASSED: test({Execution=NO-RUN, AirPort=Bangalore, FlightName=India Air Lines998, Date=Thu Apr 10 00:00:00 IST 2014, FlightNumber=10011.0})
PASSED: test({Execution=NO-RUN, AirPort=Hyderabad, FlightName=Emirates332, Date=Sun Jun 22 00:00:00 IST 2014, FlightNumber=10012.0})

===============================================
    Default test
    Tests run: 3, Failures: 0, Skips: 0
=============================================== 

Watch Demo

<< Previous

No comments:

Post a Comment