How to Perform Data Driven Testing in SoapUI Pro – SoapUI Tutorial #14

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 is often time consuming. This can be overcome through Data driven testing in SoapUI pro.

SoapUI Data Driven Testing

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 in to the corresponding variables present in the scripts. For example, let us take login form. This form usually contains user name and password fields. During functionality testing of the login screen, we need to prepare the test data with different combinations of the user name 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 user name 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.

Data Driven Testing 1

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 keyword driven framework, we prepare test data like data tables along with the keywords. There are several components available in 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, 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 check point 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.

Driver Script

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 run time 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 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 new project in SoapUI Pro, prepare test data based on the input request for the web service as shown in the below screenshot.

Data Driven Testing 2


Once test data is ready, open SoapUI Pro and follow these steps.

Step 1: Create a SOAP project using (http://www.webservicex.com/CurrencyConvertor.asmx?wsdl)

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:

Data Driven Testing 3

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 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 check box. 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.

Data Driven Testing 55

13) Finally click OK to populate the data present in the bottom of the section.

Data Driven Testing 66

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.

Conclusion:

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.




Recommended reading

5 comments ↓

#1 makarand a

hello.
Thank you for sharing these tutorials.

#2 Sumit bhandari

can ddt done in free version of soapui or its part of pro version only?

#3 Gaurav Khurana

Good one.. very easy to perform this heavy task… thanks for sharing…

where can we see all inputs and output records ???

#4 Gaurav Khurana

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);

#5 Victoria

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

Leave a Comment