In testing, we deal with huge data sets. It could be user login data, form data, locator values, etc. It is not feasible to use hardcoded data in test scripts all the time, especially when the test data is huge. Here data driven framework comes to rescue.
Data driven framework is a testing framework that uses external sources to store and manipulate test data. These sources could be excel sheets, databases, etc. Assume we have to validate the registration page for 1000 users, each having different sets of data values. In this scenario, we can store this data in excel or database and then retrieve/ manipulate it using the code.
Helper methods are written to manipulate the data from external sources. ReadExcel is one of the class in our data driven framework which contains methods to retrieve data from excel.
Download the ReadExcel class from https://github.com/DhawalGit/ReadExcelUtility.git and start exploring it. No need to understand the code, rather focus on how to use its methods to manipulate data from excel.
Components of Data Driven Framework
In this tutorial, we will be working on a live demo website to implement the data driven framework. Our framework will consist of the following components:
- Java maven project for build management.
- TestNG as the testing framework.
- log4j for logging purposes.
- TestNG Listeners to take appropriate actions based on the status of the test.
- Extent Report to generate the test execution report.
Apart from these components, we will also implement:
- Data provider and helper methods to manipulate the excel data.
- TestBase class which will work as a starting point of execution. This class will be extended by all test classes, and other classes, if applicable. Generic methods will also be created in this class.
- Generic methods – more on it in upcoming tutorials.
The demo application to learn the data driven framework is https://parabank.parasoft.com/parabank/index.htm
This is a sample banking application which we can use for training purposes. Feel free to register yourself with some dummy values and log in. Familiarize with the application and understand its flow.
The user created in this demo application resets after a day, so do not panic if you are not able to log in the next day. Just register again and you are good to go. In the next tutorial, we will start by creating the framework.