Test Data in automation framework

Data Set / Test Data

Data set stores the data files, Script reads test data from external data sources and executes test based on it.

Typically the data input can be anything:

  • MS Excel files
  • Data base
  • Text files
  • XML files….etc.

External test data must be easily editable by test engineers without any programming skills. Excel files are the ones that used most often and are familiar with it.

Data sets increases test coverage by performing testing with various inputs and reduce the number of overall test scripts needed to implement all the test cases

Data Set / Test Data Examples

The below is the excel sheet for "Add User with Valid Data"

pass valid data in automation

In the above sheet, we are trying to add two records by filling all the fields. After entering the data in respective fields and clicking on submit button, it will display a success message which tool will get and compare with Actual and Expected.

 The below is the excel sheet for "Add User with invalid Data" 

pass invalid data

In the above example, we are trying to add four records with invalid details.

For the First row, we are passing an empty 'first name' which is a required field. When we click on submit button, it will display a message as 'Please enter first name'. We should now validate if the message displaying is as expected.

Why and How to use Data Set / Test Data:

We use test data to increase test coverage with valid and invalid data.

Say suppose, if there are 20 fields in the application. And we need to check different cases by passing different values.

If there are fields related to banking information, we need to validate and restrict the user not to enter junk or invalid data.

There are cases were you may need to check calculation / percentage by adding more number of records. In such cases we have to use data set and pass different values.

We need to make sure to identify the number of fields in the function / page and define the number of columns. On the basis of these columns, data will be provided to input fields in the application.

We should define a column called Output and provide the respective message based on the data provided by the user. To provide the result/status, tool should compare with expected and actual results. Here the output is nothing but the expected. Tool will get the actual and compare with the expected data provided by the user.

Selenium Tutorials: 

Comments

Hi,

Can you please help us with the java program to access test data from excel sheet to Data Provider method using Apache POI(using XSSF version for xlsx)?

Thanks
Bhabani

File src=new File("Path of the Excel file")
FileInputstream fis=new File InputStream(src);
XSSFworkbook wb=new XSSFWorkbook(fis);
XSSFSheet wsh=wb.XSSFsheet(sheetIndex);

for(int i=0;i<=wsh.getLastRow();i++){
system.out.println(wsh.getrow(i).getcell(0).getstringcellvalue());
}

Note: while adding above code u will find error ,so to remove above error's import below packages
import java.io.File;
import java.io.FileInputStream;

I was looking for code snippet in post itself...but thanks to share code snippet...

This really help in developing good programming

Add new comment

Image CAPTCHA