Understanding Data Driven Testing in SoapUI Pro:
In this SoapUI Pro tutorial, we are going to see Data Driven Testing using SoapUI Pro. Performing load testing and performance testing with huge data are often time-to consume. This can be overcome through Data driven testing in SoapUI Pro.
What You Will Learn:
What is Data Driven Testing?
Reading test data through the test scripts for and iterating execution multiple times is known as data driven testing. Test data is pre-prepared based on the requirements in external sources that could be any of the following:
- Excel Files
- CSV Files
- ODBC Sources
- SQL / ADO Objects
While running data driven scripts, it will fetch the data from external data source file and then put into the corresponding variables present in the scripts. For example, let us take login form. This form usually contains the user name and password fields. During functionality testing of the login screen, we need to prepare the test data with different combinations of the username and password and there should be variables to obtain the data in the script correspondingly.
When we call the web service from SoapUI data source test step, it will read first set username and password. And then it will assign the values to the corresponding variables in the script. After that, the web service will start the process internally with the username and password.
Take a look at the flow diagram of common data driven testing. This can be implemented via SoapUI pro.
Keyword Driven Testing
Keyword driven testing is a software testing type applicable for both manual and automated testing (most commonly used). It is also called table driven testing. Even though this is quite simple, it does need more time to collect keywords and appropriate functionalities.
In a keyword driven framework, we prepare test data like data tables along with the keywords. There are several components available in the keyword driven testing framework. They are
- Control File
- Test Cases File
- Startup Script
- Driver Script
- Utility Script
The “Control File” contains test scenarios to be executed/automated. When testing from the initial stage, the user has to select the particular test scenario from the data file. This will be determined based on the flag ( Yes / No ) present in the data file or excel file.
“Test Cases File” component contains the detailed steps of flow to be executed and this will be prepared in the form excel containing keywords, objects, parameter and checkpoint columns.
Next component is “Startup Script”. This is the first executable script which instantiates the objects and reads the data from the content file. After that, it will start executing the test scenarios that are marked as Yes in the control file.
The driver script is responsible for reading test case file and validates the keywords. Then it will call the respective utility script functions based on the keywords available in the test case file. Apart from this, we need to handle the runtime errors in the driver script itself.
It consists of relevant logical methods/functions based on the keywords. These scripts will be generic and can be utilized across the applications.
Detailed steps on how to perform data driven testing in SoapUI Pro:
This can be done using Excel, CSV or SQL through JDBC drivers
We will use CurrencyConvertor web service to practice. Before creating the new project in SoapUI Pro, prepare test data based on the input request for the web service as shown in the below screenshot.
Once test data is ready, open SoapUI Pro and follow these steps.
Step 1: Create a SOAP project
Step 2: Add test suite and test case steps with the name of “CurrencyConvertorSoapTestSuite” and “ConversionRateTestCase” respectively
Step 3: Add service request under the test case as below:
Next, we configure the data source test step as described below:
1) Double click on the data source test step present under the project tree
2) In the right side screen, select Excel option from the data source drop down
3) SoapUI displays Configuration screen with the File, Worksheet, Start at Cell and Ignore Empty options.
4) File option should be filled with the valid file name selected from a local computer. Next enter the exact worksheet name in the Worksheet text field.
5) Following that, “Start At Cell” text field has default cell value as “A1”. Change if needed.
6) The “Ignore Empty” option helps us to avoid processing blank cells from the selected cell range. If it is checked, SoapUI will not consider the blank cells from the worksheet.
7) Click on the Browse button to select excel file stored in the hard drive
8) Enter the worksheet name as present in the original excel file. Let us specify “Sheet1” as we have entered the test data in the Sheet1.
9) Leave the default Cell name and check the checkbox. Next, we need to add Property names according to the excel headers name. Add property name icon will be present in the toolbar with the (+) symbol.
10) When all the required property names are added, we can execute the data source.
11) Click Run icon to start the execution which loads the test data to the SoapUI grid
12) Now SoapUI Pro will prompt us to specify the number of rows to be fetched from the excel file. If we need all the rows means, we can specify as zero. See the below screenshot for your reference.
13) Finally, click OK to populate the data present in the bottom of the section.
14) To iterate row by row during execution of the test suite, add a data source loop under the test suite where the data source test step is added.
15) For that right click on the test steps node and then click Add Step -> Data source Loop
16) Enter data source name in the Add Step popup and then click OK
17) After adding data source loop, we need to configure data source step and target step. For that, right click on the data source loop step and click “Configure” option. Make sure data source step should be “data source” and target step as “conversion rate”
18) Click OK to close the popup
Now it is time to execute the test suite by passing various input data. Double click on the test suite name and then click Run icon. After the execution of the test suite, SoapUI Pro will show us the test results.
This is a really useful feature to maximize the amount of testing with faster and in an enhanced fashion. However, it is sensitive to changes made to the UI during future releases. It is easy to recover by making appropriate changes to the data tables.
The next SoapUI tutorial is the last one in the series and will talk about exporting requests and responses to external files.
Please post your comments and questions below.