Thursday 20 August 2015

Get Microsoft Office/ Excel Name Function in Java

Retrieve Microsoft Excel Name and Office Path In JAVA


I have implemented an office name parsing function to reterieve which Office is installed in our machine. This code is written in Java and can be used to Automate Excel .. 

This function Performs Following Steps :

1) Find Office Excel Path Dynamically.
2) Open Excels
3) Parse the path to find which Excel is installed.

Note:- I have used parsing for Excel 2013, Excel 2010, Excel 2007 you can extend it for other office Names

public static String getofficeName()
    {
    Process p;
try {
p = Runtime.getRuntime().exec
     (new String [] { "cmd.exe", "/c", "assoc", ".xls"});

           BufferedReader input =
             new BufferedReader
               (new InputStreamReader(p.getInputStream()));
           String extensionType = input.readLine();
           input.close();
           // extract type
           if (extensionType == null) {
             System.out.println("no office installed ?");
             System.exit(1);
           }
           String fileType[] = extensionType.split("=");

           p = Runtime.getRuntime().exec
             (new String [] { "cmd.exe", "/c", "ftype", fileType[1]});
           input =
             new BufferedReader
               (new InputStreamReader(p.getInputStream()));
           String fileAssociation = input.readLine();
           // extract path
           String officePath = fileAssociation.split("=")[1];
           officePath = officePath.split("/")[0];
           System.out.println(officePath);
   
           if( officePath.contains("Root"))
  {
            String[] officePath1 = officePath.split("Root\\\\", 2);
            a = officePath1[1];
            a  = a.split("\\\\")[0];

            if (a.equalsIgnoreCase("Office15"))
            {
            OfficeName = "Excel 2013";
           
            else if (a.equalsIgnoreCase("Office14"))

    {

    OfficeName = "Excel 2010";
   
            
        else if (a.equalsIgnoreCase("Office12"))

    {

    OfficeName = "Excel 2007";
    }
    }
    else
    {
    String[] officePath2 = officePath.split("Office\\\\", 2);
    a = officePath2[1];
    a  = a.split("\\\\")[0];

    if (a.equalsIgnoreCase("Office14"))

    {

    OfficeName = "Excel 2010";
    }
   
    else if (a.equalsIgnoreCase("Office15"))
        {
        OfficeName = "Excel 2013";
       
    else if (a.equalsIgnoreCase("Office12"))

    {

    OfficeName = "Excel 2007";
    }
   
    }

      }catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }
       
return OfficeName;

 }
    

Wednesday 12 August 2015

Sikuli With Java For Testers

Sikuli With Java For Testers

Introduction:

Sikuli is an open source tool to automate and test graphical user interfaces (GUI) using images (screenshots).

As, Sikuli is based on image recognition, it waits for anything to appear on screen and, click, type etc. according to the specified identifiers. The identifiers are specified by images. Sikuli triggers GUI interactions based on the image visual match, the image which we have passed as the parameter along with all methods.

For example, if there is a Flash component on the web page with a "Next" button, an image of the "Next" button could be captured using the Sikuli, and stored. Then with the Java code the "Next" button could be identified and clicked. In-addition, the core of Sikuli Script is written in Java, which means you can use Sikuli Script as a standard JAVA library in your program.

Sikuli Can Be Useful When:

  1. When we are testing Legacy apps which are designed without a thought towards testability and thus ids were not specified by the developer
  2. When we have to be particular about UI which has lot of images and flash content on the webpage
  3. When we have to deal with an application like Google maps, Excel
  4. It can also be used to test non-browser GUI applications

    Common Functions of Java I Used In Sikuli Framework

1)Absolute Path



2) CSV Read Functions...




3) Send Email Function




Prerequisite

1. Download and install sikuli from for more information visit link "http://www.sikuli.org/download.html 
2. Download and install java 1.6
3. Download and setup eclipse with Test NG

I have created a sikuli script in which I open notepad, type some text and save file into system.

Step by Step working

1. Create a java project in to your eclipse.
2. Add "testng.jar" and "sikuli-script.jar" to your eclipse library.
3. Create a images folder into your java project as below.  
4.  Get images of using Sikuli IDE and put into images folder.
5. Create a java class into src folder.
6. Import sikuli classed and create Screen class object. as below java code:

package com.test;

import org.sikuli.script.App;
import org.sikuli.script.FindFailed;
import org.sikuli.script.Screen;
import org.testng.annotations.Test;

public class SikuliTest {

    public Screen screen;
    
    @Test
    public void tesSikuli() throws InterruptedException, FindFailed
    {
        //open note pad application
        screen =new  Screen();
        App.open("notepad.exe");
        Thread.sleep(2000);
        
        //type text notepad
        screen.type("images/InputFiled.png", "Testing sikuli with Test NG");
        Thread.sleep(2000);
        
        //click on file menu
        screen.click("images/FileMenu.png", 20);
        Thread.sleep(2000);
        
        //click on save submenu
        screen.click("images/SavesubMenu.png", 20);
        Thread.sleep(2000);
        
        //select file input field and type path 
       screen.click("images/FilePathInput.png", 20);
        screen.type("images/FilePathInput.png", "C:\\test.txt");
        Thread.sleep(2000);
        
        //click save button
        screen.click("images/SaveButton.png", 20);
        Thread.sleep(2000);    
        
    }
}

7. Right click on eclipse test scripts and chose Run As > TestNG Test and click.
8. After successfully run you can see eclipse console log as below screen.


Tuesday 6 January 2015

Selenium Testing Important URLs



http://www.mkyong.com/



http://whytotest.blogspot.in/2010/05/selenium-test-framework.html

http://anoopjshetty.wordpress.com/2012/04/19/behaviour-driven-development-bdd-in-net-using-specflow-selenium-and-nunit/

http://codedetective.blogspot.in/2011/11/setting-up-selenium-webdriver-using-c.html

http://help.utest.com/testers/crash-courses/functional/automation-tools--selenium-102

http://www.savevid.com/video/selenium-video-training-datadriven-framework-and-hybrid-framework-comparison.html

http://testng.org/doc/index.html

http://selenium-tutorial.blogspot.in/2012/04/uploading-file.html

http://oxpedia.org/wiki/index.php?title=Automated_GUI_Tests

http://xebee.xebia.in/2012/05/29/creating-automation-framework-using-selenium-and-test-ng-2/

http://www.way2automation.com/selenium_tutorial/selenium-hybrid-datadriven-keyword-framework

-tutorial.html

http://www.seleniumwiki.com/selenium-rc/selenium-keyword-driven-framework/


http://executeautomation.com/blog/blog_mod/data-driven-testing-in-selenium-using-jxl-part-2/

http://code.google.com/p/selenium/wiki/AdvancedUserInteractions

http://www.kavinschool.com/content/selenium-tuition-bayarea/39-selenium-course/54-advanced-s

elenium-using-java-language

http://www.ijcst.com/vol23/1/prasanth.pdf

http://code.google.com/p/selenium/wiki/PageFactory

http://learnseleniumautomation.blogspot.in/2012/03/window-handle-example-with-selenium.html

http://www.ibm.com/developerworks/web/library/wa-seleniumgrid/index.html

http://www.8bitavenue.com/2012/03/gui-testing-using-sikuli-and-java/

http://eureka.ykyuen.info/2010/06/26/selenium-integrate-the-selenium-tests-into-maven-build/

http://www.way2automation.com/

http://mearra.com/blogs/jani-palsamaki/creating-and-running-simple-selenium-webdriver-test

http://code.google.com/p/selenium/wiki/SeleniumEmulation

http://automation.youplayoff.com/category/selenium/


http://qaselenium.blogspot.in/2011/01/selenium-automation-framework-design.html

http://seleniumexamples.com/blog/examples/selenium2-in-net-framework/

http://robotframework-seleniumlibrary.googlecode.com/hg/doc/SeleniumLibrary.html?r=2.8

https://blogs.oracle.com/rajeshthekkadath/

http://en.wikipedia.org/wiki/Selenium_%28software%29

http://www.f14testing.com/archives/1532

http://functionaltestautomation.blogspot.in/2009/10/dataprovider-data-driven-testing-with.html

http://www.javacodegeeks.com/2012/04/integration-testing-with-selenium.html

http://selenium.googlecode.com/svn/trunk/docs/api/java/org/openqa/selenium/html5/package-summary.html

http://sauceio.com/index.php/2011/12/selenium-testing-framework-part-3-putting-it-all-togeth

er/

http://selftechy.com/2011/06/02/parameterization-of-selenium-tests-with-microsoft-excel

http://sauceio.com/index.php/2011/11/selenium-testing-framework-pt-2-base-classes/

http://www.kavinschool.com/content/selenium-tuition-bayarea/39-selenium-course/54-advanced-s

elenium-using-java-language

http://hop2croft.wordpress.com/2011/09/17/spring-mvc-basic-example-with-maven/

http://www.seleniumwiki.com/selenium-rc/selenium-rc-test-framework-using-xml-data-structure/

http://marcovaltas.com/2009/02/19/running-selenium-with-testng.html

http://blog.varunin.com/

http://en.wikipedia.org/wiki/Data-driven_testing

http://thangselenium.blogspot.in/


http://sqahome.blogspot.in/2010/06/selenium-framework-structure-java.html

http://www.wallix.org/2011/07/26/how-to-use-robotframework-with-the-selenium-library/

http://qtpselenium.com/selenium-tutorial/selenium-training-hybrid-framework/

http://automationtestingsimplified.wordpress.com/2011/08/18/how-to-do-data-driven-testing-us

ing-selenium-2-webdriver/

http://wiki.zimbra.com/wiki/Testing:_Selenium:_ZimbraSelenium_SampleTestCase

http://code.google.com/p/selenium/wiki/PageObjects

http://marakana.com/bookshelf/selenium_tutorial/project.html

http://in.linkedin.com/pub/selenium-rc-webdriver-tutorial/51/b7/49

http://code.google.com/p/robotframework-seleniumlibrary/

http://blog.codecentric.de/en/2010/07/file-downloads-with-selenium-mission-impossible/

http://www.pushtotest.com/testing-with-selenium#tutorial

http://seleniumrc.wordpress.com/

http://qtp-help.blogspot.in/p/selenium-training.html

http://www.seleniumtests.com/2012/01/selenium-2-methods-are-no-more-weird.html?utm_source=BP_recent

http://candidjava.com/keyword-this-in-java-with-example-program

https://github.com/Ardesco/Ebselen/blob/master/ebselen-core/src/main/java/com/lazerycode/ebselen/customhandlers/ExcelHandler.java

http://shanmugavelc.blogspot.in/2010/09/datadriven-test-using-selenium-nunit.html

http://vimeo.com/46412735

http://computer.motiontopic.net/s/Selenium-Data-driven-framework

Selenium Grid

http://code.google.com/p/selenium/wiki/Grid2
http://deors.wordpress.com/2012/02/02/selenium-webdriver-grid-2/
http://technologyandleadership.com/30-feet-view-of-test-automation-framework-with-selenium/

selenium with flash

http://code.google.com/p/flash-selenium/


http://www.softwaretestingtutorials.org/packages/


selenium with ant

http://hedleyproctor.com/2011/07/automating-selenium-testing-with-testng-ant-and-cruisecontrol/


selenium Index

http://www.sqaforums.com/showflat.php?Cat=0&Number=716574&Main=714887

http://www.citehr.com/374186-best-institute-learning-selenium-testing.html

http://forum.softwaretestinghelp.com/index.php?topic=446.0

http://grokbase.com/p/gg/selenium-users/125bve6d3m/is-anyone-provide-me-code-for-data-driven-testing-in-selenium-webdriver-in-java-junit-framework-plz-it-is-urgent

http://ahmedabad.olx.in/selenium-training-in-ahmedabad-iid-249982843


http://www.automation.lifegoeasy.com/Selenium-Webdriver-Java-Syllabus

http://seleniumtraining.weebly.com/selenium-automation.html

http://www.360logica.com/test-automation-services/functional-automation-framework


Testng

http://ravisha-selenium.blogspot.in/

DataDriven framework

http://executeautomation.com/blog/tag/data-driven-testing/

http://functionaltestautomation.blogspot.in/2009/10/dataprovider-data-driven-testing-with.html

http://qtpselenium.com/selenium-tutorial/selenium-training-data-driven-framework/

http://automationtestingsimplified.wordpress.com/2011/08/18/how-to-do-data-driven-testing-using-selenium-2-webdriver/

http://automationtestingsimplified.wordpress.com/2011/05/31/hybrid-testing-data-keyword-driven-using-selenium/

http://www.softwaretestingclub.com/video/selenium-data-driven-automation-framework-selenium-rc-junit

http://testerinyou.blogspot.in/2010/10/how-to-do-data-driven-testing-using.html

http://www.seleniumelearn.com/free-selenium-training-tutorial-videos

http://www.seleniumwebdriver.com/webdriver-tutorials/advance-selenium-rc-webdriver-tutorials-with-frameworks/msg16333/?PHPSESSID=b0af0d93c11942fedcc8c26d0ac04ec0#msg16333

http://lrnselenium.com/?category_name=automation-framework

http://selenium-suresh.blogspot.in/2012/07/data-driven-testing-using-selenium-rc_24.html

http://hedleyproctor.com/2011/07/automating-selenium-testing-with-testng-ant-and-cruisecontrol/

http://testingchronicle.blogspot.in/2012/05/selenium-keyword-driven-and-data-driven.html

https://sites.google.com/site/joinqahub/Selenium-tutorial-for-beginners

http://executeautomation.com/blog/blog_mod/data-driven-testing-in-selenium-using-jxl-part-2/

http://www.gcrit.com/forums/viewtopic.php?f=29&t=109
http://zomobo.net/keyword-driven
http://www.youtube.com/watch?v=KL4Y7cWiK4g&feature=player_embedded
http://www.youtube.com/watch?v=JMZeaF0ST4w&feature=channel
http://www.youtube.com/watch?v=1ZV8pZAKkDQ&NR=1
http://www.youtube.com/watch?v=A6ND9pRRBY8&NR=1

http://www.whatsontv.co.uk/video/youtube/search/keyword-driven

Thursday 10 July 2014

Data corruption during testing

Data corruption during testing

How often do find corrupt data in testing databases. Sometimes corrupt data results in various system failures that were not really the code errors or bugs. This is a challenge that testers may face while testing an application that has data dependency.

Generally more than one tester works on these applications simultaneously and as we all know testers are good at modifying data as per our needs. In the process we modify data, perform our testing and then forget about the data that we modified it sounds so easy going and cute, correct? But if someone else picks up that modified data and performs another operation, there is a possibility that the testing may fail. Then we are happy that we found a bug, we log a bug, and approach a developer like a master telling him that there is a major bug in the system. The developer will then debug the code for the bug and find that there is nothing wrong with the code, he again approach you and say that the code is just fine. Then how did the bug arise?

The answer here is that the bugs have been encountered due to data discrepancy in the database. The code would just run fine on the correct data but as the data is incorrect, the code is unable to determine the correct behaviour that should be performed for such "discrepant" data
Data discrepancy is as serious issue as a major code error. Just imagine a newspaper saying "9000 people killed in bus accident" while it should say "9 people killed in a bus accident". The impact is huge. It’s just like presenting an incorrect application to the client. It may even result in a very angry client or a client laughing like it is taunting you. The end result is EMBARRASSMENT!!!

There are solutions to prevent data discrepancy in a database.

1. Take a backup: Before modifying any data in the database take a backup of the database to ensure that if any woolly mammoth is encountered we can make it disappear by a database restore.

2. Revert back data manually: If you think database backup and restore are too lengthy process and there is not enough time for such activity, just revert back the data that you modified to its original state. This can be done using an UPDATE SQL query.

3. Division of data: Data can be divided among the number of testers working on the application. This helps as each member performs functionality on the data provided to them and hence keeps the data very much clean.

4. Minimal Use of Update and Insert: While using SQL, the use of update and insert should be minimal and should be used only if required. Don't just use update and insert just for fun in the testing database.


5. Ask before you do: One should always ask a DBA or the senior database analyser for any changes being made to the testing database. This will ensure that the DBA is aware of the changes and can handle any data related discrepancy in the database.

Thanks,

Mohit Bhatia
View Mohit Bhatia's profile on LinkedIn

ETL Testing

ETL Testing Process:


Similar to any other testing that lies under Independent Verification and Validation, ETL also go through the same phase.

-Business and requirement understanding
-Validating
-Test Estimation
-Test planning based on the inputs from test estimation and business requirement
-Designing test cases and test scenarios from all the available inputs
-Once all the test cases are ready and are approved, testing team proceed to perform pre--execution check and test data preparation for testing
-Lastly execution is performed till exit criteria are met
-Upon successful completion summary report is prepared and closure process is done.

It is necessary to define test strategy which should be mutually accepted by stakeholders before starting actual testing. A well-defined test strategy will make sure that correct approach has been followed meeting the testing aspiration. ETL testing might require writing SQL statements extensively by testing team or may be tailoring the SQL provided by development team. In any case testing team must be aware of the results they are trying to get using those SQL statements.

Difference between Database and Data Warehouse Testing


There is a popular misunderstanding that database testing and data warehouse is similar while the fact is that both hold different direction in testing.

 Database testing is done using smaller scale of data normally with OLTP (Online transaction processing) type of databases while data warehouse testing is done with large volume with data involving OLAP (online analytical processing) databases.

 In database testing normally data is consistently injected from uniform sources while in data warehouse testing most of the data comes from different kind of data sources which are sequentially inconsistent.

We generally perform only CRUD (Create, read, update and delete) operation in database testing while in data warehouse testing we use read-only (Select) operation.
Normalized databases are used in DB testing while demoralized DB is used in data warehouse testing.

There are number of universal verifications that have to be carried out for any kind of data warehouse testing. Below is the list of objects that are treated as essential for validation in ETL testing:

- Verify that data transformation from source to destination works as expected
- Verify that expected data is added in target system
- Verify that all DB fields and field data is loaded without any truncation
- Verify data checksum for record count match
- Verify that for rejected data proper error logs are generated with all details
- Verify NULL value fields
- Verify that duplicate data is not loaded
- Verify data integrity

ETL Testing Challenges:

ETL testing is quite different from conventional testing. There are many challenges we faced while performing data warehouse testing. Here is the list of few ETL testing challenges I experienced on my project:
- Incompatible and duplicate data.
- Loss of data during ETL process.
- Unavailability of inclusive test bed.
- Testers have no privileges to execute ETL jobs by their own.
- Volume and complexity of data is very huge.
- Fault in business process and procedures.
- Trouble acquiring and building test data.
- Missing business flow information.
Data is important for businesses to make the critical business decisions. ETL testing plays a significant role validating and ensuring that the business information is exact, consistent and reliable. Also, it minimizes hazard of data loss in production.
Hope these tips will help ensure your ETL process is accurate and the data warehouse build by this is a competitive advantage for your business.
Moreover, ETL or Data warehouse testing is categorized into four different areas irrespective of technology or ETL tools used:
New Data Warehouse Testing – New DW is built and verified from scratch. Data input is taken from customer requirements and different data sources and new data warehouse is build and verified with the help of ETL tools.
Migration Testing – In this type of project customer will have an existing DW and ETL performing the job but they are looking to bag new tool in order to improve efficiency.
Change Request – In this type of project new data is added from different sources to an existing DW. Also, there might be a condition where customer needs to change their existing business rule or they might integrate the new rule.
Report Testing – Report are the end result of any Data Warehouse and the basic propose for which DW is build. Report must be tested by validating layout, data in the report and calculation.

Why do organizations need Data Warehouse?

Organizations with organized IT practices are looking forward to create a next level of technology transformation. They are now trying to make themselves much more operational with easy-to-interoperate data. Having said that data is most important part of any organization, it may be everyday data or historical data. Data is backbone of any report and reports are the baseline on which all the vital management decisions are taken.
Most of the companies are taking a step forward for constructing their data warehouse to store and monitor real time data as well as historical data. Crafting an efficient data warehouse is not an easy job. Many organizations have distributed departments with different applications running on distributed technology. ETL tool is employed in order to make a flawless integration between different data sources from different departments. ETL tool will work as an integrator, extracting data from different sources; transforming it in preferred format based on the business transformation rules and loading it in cohesive DB known are Data Warehouse.

What is a staging area?

Do we need it? What is the purpose of a staging area?
Staging area is place where you hold temporary tables on data warehouse server. Staging tables are connected to work area or fact tables. We basically need staging area to hold the data, and perform data cleansing and merging, before loading the data into warehouse.


Decoding Data Mapping Sheets - ETL Process

An ETL (Extract Transform Load) process is all about moving a variety of data from Source System to the destination Data Warehouse System by taking data through a number of extraction, transformation, data cleansing & data validation processes.

Just imagine how easy it will get for someone as an ETL developer if he gets a chance to visualize all the transformations & business rules up front in an easy to interpret format. This is where mapping sheets come into picture.  

A carefully designed mapping sheet up-front can save a lot of pain as handling mapping information increasingly gets difficult as application grows with time. Only downside of using them is it takes good effort to create them & then keeping them up-to-date. But, trust me, rewards of using them easily outnumber the pain of not maintaining one as the system grows overtime
Each data migration project uses mapping sheets in one form or the other but the one which I have used too often & has worked exceptionally well for me is what I am detailing in this here.

To start with a sample Mapping Sheet would look something like this for any given entity as represented in Figure 1. The sheet can be extended further by using multiple sheets in the Excel workbook to represent other entities of the system.

Fig 1 – Sample Mapping Sheet structure

Generally, the extreme left of the sheet represents data from the Source System or the staging area. The middle layer represents data validation, data verification, data cleansing & business rule validation with a number of data-centric transformation rules in place. There can be more than 1 transformation layer in the centre depending upon how complex the ETL process is. The extreme right mostly represent Data Warehouse system.

In the Figure 2 below, I have taken example of Employee table in staging area to represent how actual table structure from database gets represented in a mapping sheet.




















Carefully looking at the snapshot in figure 2, it provides almost all the information related to a table in a database. The information includes everything like - Schema name (stg), Name of the Table [Employee] along with name of the columns, data types & whether they allows NULL or NOT NULLS values. For eg - EmployeeID is INT & NOT NULL whereas EmployeeName is going to be varchar(255) NULL column.

On a similar line, mapping sheets can be extended to further represent structure of the given tables across different layers. Figure 3 below further helps you visualize how a field gets mapped, validated & transformed through different layers of the ETL process while being migrated from Source System to ODS to DW.

Fig 3 – Transformation rules at the table/field level

 Another efficient use of mapping sheet would be to documnt Business rules in layman’s term against respective field right next to them. Please refer to Figure 4 below. The figure represents only a selective few & a very basic level transformation rulesPlease note, the transformation rules represented here are only from informative purpose & real time transformation could vary considerably depending upon project requirements. The mapping sheets only works as placeholders to store transformation information.

Some of the sample business rules could be like

1.  Use database defaults to set to Current Date & Time for CreatedOn, ModifiedOn fields.
2.  Use SQL Case statement to set a field to an integer value in warehouse depending upon text information coming in from source feed.
3.  Placeholder to store I, U, D flags in ODS layer to perform respective actions in warehouse for a given entity – just to name a few
4.  Other transformations would be something like these -


Figure 4 – Sample Transformation Rules :


Some of the key points that must be considered while designing a mapping information document:    


1        Design staging area with minimal constraints/indexes and with no or minimum data integrity checks in place. Consideration for Extraction process must be to load data from Source System as quickly as possible with minimal data leakage. Ideally, data type in this layer should be minimally restrictive to allow full data to pass through to staging area without any data loss. Like allowing NULLs, data size sufficiently big enough to hold data from feeding source system.

2        Operational Data Store Layer - In this layer most of the business rules are defined and data types are generally tightly coupled with data types in warehouse layer. Most of the data transformations, error handling & data filtering are done in this layer. An ideal ODS layer should be able to maintain audit trail information to keep track of I, U, D operations to Data Warehouse. In this example, “Action" field in ods.Employee table can be used to maintain current state of a record throughout the life cycle of ETL process.                         


3        Data warehouse Layer - This layer contains only current version of data. The records normally gets Inserted, Updated & Deleted in Data Warehouse depending upon incoming “Action” field from ODS source. Normally, only selective few transformation are performed in this layer, the ones which are specific to data available in data warehouse                      

With this, I will now sign off on this topic. I have tried keeping this information in its basic & simplest form so I hope this information will come handy in your respective projects. Please do share your inputs, feedback & comments & I will be more than happy to amend/improve this posting further.


Decoding Part Copied and Reference: - www.msbigeek.com


Thanks,

Mohit Bhatia
View Mohit Bhatia's profile on LinkedIn

Thursday 27 December 2012

How to calculate Statement, Branch/Decision Coverage



How to calculate Statement, Branch/Decision Coverage

HOW TO CALCULATE STATEMENT, BRANCH/DECISION AND PATH COVERAGE FOR ISTQB EXAM PURPOSE


Statement Coverage: (Find shortest path such that all nodes are covered at-least once)

In this, the test case is executed in such a way that every node is traversed at-least once.

Branch/Decision Coverage: (Find shortest path such that all the Edges are covered at-least once)

Test coverage criteria requires enough test cases such that each condition in a decision
takes on all possible outcomes at least once, and each point of entry to a program or
subroutine is invoked at least once. That is, every branch (decision) taken each way,
true and false. It helps in validating all the branches in the code making sure that no
branch leads to abnormal behavior of the application.



Path Coverage:(Find all the paths from source to destination)

In this the test case is executed in such a way that every path is executed at least once.
All possible control paths taken, including all loop paths taken zero, once, and multiple
(ideally, maximum) items in path coverage technique, the test cases are prepared based
on the logical complexity measure of a procedural design. In this type of testing every
statement in the program is guaranteed to be executed at least one time. Flow Graph,
Cyclomatic Complexity and Graph Metrics are used to arrive at basis path
How to calculate Statement Coverage, Branch Coverage and Path Coverage?

Draw the flow in the following way-
Nodes represent entries, exits, decisions and each statement of code.
Edges represent non-branching and branching links between nodes.

Example:
Read P
Read Q
IF P+Q > 100 THEN
Print “Large”
ENDIF
If P > 50 THEN
Print “P Large”
ENDIF
Calculate statement coverage, branch coverage and path coverage.




The flow chart is-



Statement Coverage (SC):

To calculate Statement Coverage, find out the shortest number of paths following
which all the nodes will be covered. Here by traversing through path 1A-2C-3D-E-4G-5H all
the nodes are covered. So by traveling through only one path all the nodes 12345 are covered,
so the Statement coverage in this case is 1.

Branch Coverage (BC):

To calculate Branch Coverage, find out the minimum number of paths which will
ensure covering of all the edges. In this case there is no single path which will ensure coverage
of all the edges at one go. By following paths 1A-2C-3D-E-4G-5H, maximum numbers of
edges (A, C, D, E, G and H) are covered but edges B and F are left. To covers these edges we
can follow 1A-2B-E-4F. By the combining the above two paths we can ensure of traveling
through all the paths. Hence Branch Coverage is 2. The aim is to cover all possible true/false
decisions.
Path Coverage (PC):
Path Coverage ensures covering of all the paths from start to end.
All possible paths are-
1A-2B-E-4F
1A-2B-E-4G-5H
1A-2C-3D-E-4G-5H
1A-2C-3D-E-4F
So path coverage is 4.
Thus for the above example SC=1, BC=2 and PC=4.
Memorize these….
100% LCSAJ coverage will imply 100% Branch/Decision coverage
100% Path coverage will imply 100% Statement coverage
100% Branch/Decision coverage will imply 100% Statement coverage
100% Path coverage will imply 100% Branch/Decision coverage
Branch coverage and Decision coverage are same.

Thanks,

Mohit Bhatia
View Mohit Bhatia's profile on LinkedIn

Get Microsoft Office/ Excel Name Function in Java

Retrieve Microsoft Excel Name and Office Path In JAVA I have implemented an office name parsing function to reterieve which Office is in...

Get Counted