Thursday, September 5, 2013

Data Driven Framework

Data Driven Framework

In Data Driven Framework, you write scripts manually or use the automation tool to record the scripts and later on modify these scripts to add variable data.

Some facts about Data Driven Framework

- Data Driven Framework is easiest and faster to implement since you can just use record and play to record the scripts and add variable data. But the tester creating this Framework should be well versed with the underlying automation tool and the learning curve may then be longer in many cases.

- One of the other drawbacks of Data Driven Framework is that it seems to perpetuate and may be unsuitable for long run.

- Data Driven testing framework is not a good solution if you are looking to automate your regression or system tests as these are more about business functionality and less about using repetitive data.

- Whenever the SUT changes, it is possible that the change is required only with the Data or only with code or may be both. So it is possible to divide the maintenance responsibilities of the framework between different people.

A very simple example of Data Driven Framework in QTP/UFT

Below is the folder structure:



Function Library:


GUITest1:


GUITest2:


Sheet GUITest1 of Data.xls


Sheet GUITest2 of Data.xls


Script


We have two tests: GUITest1 and GUITest2. Similarly the two Sheets of Excel are named GUITest1 and GUITest2.

In the Repository1 we have added all the objects related to Login window and Flight Reservation window of Flights application.

The two tests have identical code except that they use different data from different Excel Sheets. Each test uses the sheet corresponding to its name.

Note: Make sure that before running the tests you change the location of “flight4a.exe” in both the tests and the location of Data Excel file in the Function Library. Also change the location of QTP_Tests(1) and QTP_Tests(2) in the Scripts file.

Open each test one at a time. Associate Function Library and Object Repository to it and save it.

In order to run this framework, make sure QTP is closed. Go to Command prompt and run the script.

The script opens QTP and opens each test one at a time and runs the test. The test while running calls the Function Library and the Function Library in turn imports the data from excel into QTP Data Table and use the values (Username and Password) from there.

Script--> QTP Test (GUITest1/GUITest2)--> Function Library--> Data.xls

We are opening each test one at a time and running it. The test in turn is just opening the application (Flights) using data from Excel, depicting a very simple behavior of Data Driven Frameworks.