- Advertisement -
Data driven framework is one of the most popular and being used framework. it is kind of mandatory framework which required in most of the Hybrid frameworks.
Before we move to discuss about the data driven framework, we should know, necessity of it.
Necessity: It is always not possible to test application with all possible options, same case happens with values, it is no possible execute the test case with all possible values. so we need some mechanism by which we run/execute the same test case with different data or same data. it introduces need of data driven framework. Data driven framework helps you to achieve this goal.
Data-Driven Framework:
Definition : In Raw words we can say that it is kind of framework where test data is being driven by data files such as Excel files, Text files, CVS files, even databases.
In data-driven framework the input and output values for the test are fetched from data files. These data files can be Excel files, CVS files, ADO objects, DAO objects or any ODBC source etc. these data can be manually entered in data files or automatically generated by scripts.
This has a similarity with table-driven testing in a way that our test case is encapsulated in the data file as against in the test script. The test script just remains a “driver,” or a means of delivery for the data. Here in data-driven testing, data files contain just the test data only.
Advantages of data-driven testing:
The advantages of the Data-Driven test automation framework are as follows,
a) We can create our scripts even when development of application is still going on.
b) Redundancy & unnecessary duplication of creation of automated testing scripts gets greatly reduced due to the modular type of design & due to the use of files or records for both input as well as verifying the data.
c) In case of any change in functionality, we just need to revise the particular “Business Function” script.
d) Information like data inputs or outputs, expected results get stored in the form of conveniently managed text records.
- Advertisement -
e) This permits better error handling, thereby the resulting test scripts are more robust. This is due to the fact that when a script is called, the functions return “TRUE” or “FALSE” values, instead of aborting. By having a nicely created “recovery” program, we can execute our test scripts virtually unattended.
Disadvantages of data-driven testing
The disadvantages of the Data-Driven test automation framework are as follows,
a) This calls for great expertise of scripting language required by the automation tool.
b) For every test case we need many data-files. According to the number of screens being accessed we may have many data-inputs and may require many verification. Hence the test case needs to keep the data-files in different directories.
c) The test engineer is required to re-enter the test plan data in various concerned data files in addition to managing the detailed test plan.
d) In case for creating & maintaining the data-files, we use text editor like Notepad, extra care is needed in having the desired format needed by the functions or scripts which would process the concerned files; otherwise we shall get script-processing errors due to incorrect data-file format or its content.
How it Works:
Typically, We have to create functions or methods to fetch the data from data file, in above image you can see in center there is function or method which fetch the data from data file and also write data from execution. it may be results or log, depends on how the implementation is. this Function or method stores the data from data file and provide to test case or other parts of automation framework.
Code Snippets:
Some of Code Snippets which will help you incorporate the Data driven Framework.
QTP Snippets: you can find comprehensive post here : http://qeworks.com/scripts-to-handle-folder-structure/
Selenium : It depends of which development language which you are using considering JAVA, use following code.
//add jxl jar to project //import following API reference. import java.io.File; import java.util.Date; import jxl.*; ... // inside the method write following code. Workbook workbook = Workbook.getWorkbook(new File("myfile.xls")); Sheet sheet = workbook.getSheet(0); String stringa1 = sheet.getCell(0,0).getContents(); // now stringa1 has value from excel. now you can use it as per your need. workbook.close();