In this article, we will learn in detail how to perform data driven testing in SoapUI Pro. Let’s get started.
In this SoapUI Pro tutorial, we are going to see Data Driven Testing using SoapUI Pro. Performing load testing and performance testing with huge amounts of data is often time-to-consumer. This can be overcome through Data driven testing in SoapUI Pro.
Table of Contents:
How To Perform Data Driven Testing in SoapUI Pro
What is Data Driven Testing
Reading test data through test scripts and iterating execution multiple times is known as data driven testing. Test data is pre-prepared based on the requirements of 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 the external data source file and then put it into the corresponding variables present in the scripts. For example, let us use the login form. This form usually contains the username 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 you call the web service from the SoapUI data source test step, it will read the first set username and password. It will then 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 seems 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 a 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, parameters and checkpoint columns.
The 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.
Driver Script
The driver script is responsible for reading the test case file as well as validating the keywords. It will then address 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.
Utility Script
It consists of relevant logical methods/functions based on the keywords. These scripts will be generic and can be utilized across applications.
Detailed steps on how to perform data driven testing on 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 the test data is ready, open SoapUI Pro and follow the steps given here:
Step 1) Create a SOAP project
Step 2) Add the test suite and test case steps with the name of “CurrencyConvertorSoapTestSuite” and “ConversionRateTestCase” respectively
Step 3) Add the service request under the test case as shown below:
Next, we configure the data source test steps as described below
1) Double click on the data source test steps present under the project tree
2) On the right side of the screen, select the Excel option from the data source drop down
3) SoapUI displays Configuration screen with File, Worksheet, Start at Cell and Ignore Empty options.
4) File options 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 a default cell value as “A1”. Change if required.
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 the 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 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 a property name icon that 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) SoapUI Pro will now 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 them as zero. See the screenshot given below for your reference.
13) Finally, click OK to populate the data present at 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 step 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 the data source step and target step. For that, right click on the data source loop step and click “Configure” option. Make sure that the 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 the Run icon. After the execution of the test suite, SoapUI Pro will show us the test results.
Conclusion
This is a really useful feature to maximize the amount of testing in a faster and 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 in the series and will talk about exporting requests and responses to external files.
Please post your feedback and questions in the comments section below. We would love to hear from you.
hello.
Thank you for sharing these tutorials.
Good one,, it makes life so easy.. but how to save all these results.. i added a groovy script follwoing the next tutorial ,, but its not capturing all execution results but its limited to only 1 request and response…
how can we loop the groovy to capture all results from 1st to 5th execution
def request = context.expand(‘${ConversionRate#Request}’);
log.info(request);
def response = context.expand(‘${ConversionRate#Response}’);
new File(“c:/Automation/”+a.count+”_request.txt”).write(request+response);
HI,
Is it possible to connect to a database with JDBC connection?
Also with Soap UI is it possible to test Db tables using sql query count functionality?
All I wanted is to retrieve the count of records for evert table.So it is possible to have those queries set in soapUI Pro and running them would retrieve all results at one go?
Thanks
Hi, good tutorial, is it possible to use the response values to send a new request? If anyone knows how to do it please share the answer. Thanks.
Good one.. very easy to perform this heavy task… thanks for sharing…
where can we see all inputs and output records ???
Can any one share the code of Data Driven Framework in TestNG (Without data Provider) it should have file input or output functionality.
can ddt done in free version of soapui or its part of pro version only?