Sunday, 20 July 2014

How to call "ANT Build" target's without using 'depends' attribute.

1. Below is the 'Sample XML' for calling ANT targets without using 'depends' attribute.
> Use 'antcall' for calling the target's.

Sample XML file : ANTCall.xml 
<?xml version="1.0"?>
<project name="Hello World Project" default="info">
   <target name="info">
      <echo>Calling the targest</echo>
 <antcall target="target1" />
 <antcall target="target2" />
   </target>
 
   <target name="target1">
      <echo>TARGET 1....</echo>
   </target>

   <target name="target2">
      <echo>TARGET 2....</echo>
   </target>  
</project>

Output:


2. Below sample xml for calling ANT targets using 'depends' attribute.

Sample XML file : DependsAttr.xml 
<?xml version="1.0"?>
<project name="Hello World Project" default="info">
   <target name="info" depends="target1,target2">
      <echo>Calling the targest completed</echo>
   </target>
 
   <target name="target1">
      <echo>TARGET 1....</echo>
   </target>

   <target name="target2">
      <echo>TARGET 2....</echo>
   </target>
</project>

Output:




Friday, 18 July 2014

How to include other suite files in TestNG suite.

Suppose we have application with multiple modules(say 20 modules).
If you want to create suite file for each module then we will have 20 suite file(i.e. one suite file for each module, since easy to maintain), if you want execute the test scripts for all the modules then you need to execute all the suite files one after the other. 

Is there any way to integrate all the suite files in single suite file(i.e. Main Suite file / Final Suite file).

Yes, there is a solution to integrate all the suite files in Final Suite file / Main Suite file.
Below steps/procedure show's to integrate multiple suite files in single suite file.

TestNG Sample Program's 

Module 1:
package module1;

import org.testng.annotations.Test;

public class Test1 {
  @Test
  public void test1() {
System.out.println("test1 of module1...");  
  }
}

Module 2:
package module2;

import org.testng.annotations.Test;

public class Test2 {
 @Test
 public void test2() {
System.out.println("test2 of module2...");  
 }
}

Sample Suite Files for each module:

Suite_Module1.xml :
<?xml version="1.0" encoding="UTF-8"?>
<suite name="Suite_module1" parallel="false">
  <test name="Test">
    <classes>
      <class name="module1.Test1"/>
    </classes>
  </test> <!-- Test -->
</suite> <!-- Suite -->

Suite_Module2.xml :
<?xml version="1.0" encoding="UTF-8"?>
<suite name="Suite_module2" parallel="false">
  <test name="Test">
    <classes>
      <class name="module2.Test2"/>
    </classes>
  </test> <!-- Test -->
</suite> <!-- Suite -->

Final (or) Main Suite File:
Final_Suite.xml
<?xml version="1.0" encoding="UTF-8"?>

<suite name="All Suite Files">
   <suite-files>
      <suite-file path="Suite_Module1.xml" />
      <suite-file path="Suite_Module2.xml" />
   </suite-files> <!-- Suite files-->
</suite> <!-- Suite -->

Now execute the Final Suite file(i.e Final_Suite.xml):\

Output:
------------------------------------------------------------------------------------
[TestNG] Running:
  D:\V_Drive\SW Testing\WDriver\TestNG Proj\src\Suite_Module1.xml

test1 of module1...

===============================================
Suite_module1
Total tests run: 1, Failures: 0, Skips: 0
===============================================

[TestNG] Running:
  D:\V_Drive\SW Testing\WDriver\TestNG Proj\src\Suite_Module2.xml

test2 of module2...

===============================================
Suite_module2
Total tests run: 1, Failures: 0, Skips: 0
===============================================

[TestNG] Running:
  D:\V_Drive\SW Testing\WDriver\TestNG Proj\src\Final_Suite.xml


===============================================
All Suite Files
Total tests run: 2, Failures: 0, Skips: 0
===============================================

------------------------------------------------------------------------------------

Help Links - Software Testing

Software Testing

1. How Test Planning has Upper Hand than Test Execution Phase?

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

Tuesday, 15 July 2014

Help Links - Automation Framework

Automation Framework

1. 'Data Driven Framework' (Java).
Reference:

2.Hybrid Framework(Java & Webdriver).
Reference:

3. Excel-testng: driving TestNG tests through MS Excel
Reference:
http://www.randomsync.net/2012/02/excel-testng-driving-testng-tests.html

4. Creating Keyword & Hybrid Frameworks with Selenium
Reference: http://www.guru99.com/creating-keyword-hybrid-frameworks-with-selenium.html

--------------------------------------------------------------------------------------Executing scripts from excel

1. Excel-Testng: driving TestNG tests through MS Excel
Reference: http://www.randomsync.net/2012/02/excel-testng-driving-testng-tests.html

2. Selenium Excel AddIn
Reference: https://seleniumexceladdin.codeplex.com/
--------------------------------------------------------------------------------------

1.  QTP 'Data Driven Framework'.
Reference:

2. QTP Modular Framework.
Reference:

3. QTP Linear Framework.
Reference:

Saturday, 5 July 2014

Java(Help Links) - Build Tool

Build Tool

ANT - Reports:
1. Ant task for generating XSLT report.
Reference: http://aksahu.blogspot.in/search/label/XSLT

2. Ant task for ReportNG report.
Reference: http://aksahu.blogspot.in/search/label/ReportNG

3. Ant task for generating Cobertura report.
Reference http://aksahu.blogspot.in/search/label/Cobertura

4. Ant task/script for generating TestNg report.
Reference: http://aksahu.blogspot.in/2012/03/ant-taskscript-for-generating-testng.html

5. Ant task/script for generating JUnit report.
Reference: http://aksahu.blogspot.in/2012/03/ant-script-for-generating-junit-report.html

Thursday, 3 July 2014

DDF Workbook - Version 3.0.3

Issue in 3.0.2 : 
            If test data has duplicate header's then 'Data Driven Framework'(DDF) API doesn't throw any exception. DDF-API picks the test data from the highest column number in case if there are duplicate header names in the test data.

Fixed in Version-3.0.3:
     If test data has duplicate header's then 'Data Driven Framework'(DDF) API throws exception "Header Name '<<HEADER_NAME>>' should be unique."

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

5. Set the "AH-DDF-3.0.3.jar" in java build path.
6. Set the <<POI>> API jar files in java build path, click on the link "Prerequisite and Setup" to set the mandatory <<POI>> jar files to be placed in the java build path.

                       Duplicate Header Name in test data, refer below Figure-1.
Figure-1

Source Code and results(i.e. exception) in console, refer below Figure-2.
 
Figure-2

<< Previous

DDF CSV - Version 3.0.3

Issue in 3.0.2 : 
            If test data has duplicate header's then 'Data Driven Framework'(DDF) API doesn't throw any exception. DDF-API picks the test data from the highest column number in case if there are duplicate header names in the test data.

Fixed in Version-3.0.3:
     If test data has duplicate header's then 'Data Driven Framework'(DDF) API throws exception "Header Name '<<HEADER_NAME>>' should be unique."

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

5. Set the "AH-DDF-3.0.3.jar" in java build path.

                       Duplicate Header Name in test data, refer below Figure-1.
Figure-1

Source Code and results(i.e. exception) in console, refer below Figure-2.
Figure-2

<< Previous

DDF XML- Version 3.0.3

Issue in 3.0.2 : 
    If test data has duplicate XML elements then 'Data Driven Framework'(DDF) API doesn't throw any exception, DDF-API picks the test data from the highest XML element row/line in case if there are duplicate xml elements in the test data.

Fixed in Version-3.0.3:
     If test data has duplicate element's then 'Data Driven Framework'(DDF) API throws exception "XML element '<<ELEMENT_NAME>>' should be unique.".

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

5. Set the "AH-DDF-3.0.3.jar" in java build path.

                       Duplicate Element Name in test data, refer below Figure-1.
Figure-1

Source Code and results(i.e. exception) in console, refer below Figure-2.
Figure-2

<< Previous