DataDriven testing is always comes first when evaluating any
test automation tool, and other features depends on the needs for the project.
And most of the Test Automation tools which supports DataDriven testing as paid
tools I mean to say strictly Licensed, some of the tools are less in License
price and some of them are very high, due to this reason all some of the test
automation tools creators provides Open Source tools which are less in the
features.
Now in this post I am going to describe some technique to
DataDriven testing on SoapUI Open Source tool, in which there is no DataDriven
feature present. Which helps you in saving License price. (After publishing this post one team will find me for sure, I Am Sorry Team).
So let us start, as you all know how to create project, Test
Suite and Test Case (or refer my other post for the same).
In below screen you can see the Project Test Suite and Test
Case created. In right pane, you can see the xml, which is actual request xml
for the “SendSMSToIndia” request.
Also observe there are totally three fields are present in
which we need to enter the data to it from the excel sheet.
<web:MobileNumber>?</web:MobileNumber>
<web:FromEmailAddress>?</web:FromEmailAddress>
<web:Message>?</web:Message>
Now move on to preparing the Input data for the request
fields from the excel file, to do that just follow the steps,
Open excel file and create header as same as the fields
name, here in our test request we have fields name as above so here header is
as below in excel file, ’MobileNumber’, ‘FromEmailAddress’ and ‘Message’.
Now it’s time to prepare the input excel file with required
test data, may be Valid or invalid based on the project requirement. After
successful update of the test data into the excel file, the file will looks
like below.
Now its time to add import this test data to the request xml
by using Groovy script. Write Groovy/Java code to read the Excel file and use
the SOAPUI inbuilt library functions and some groovy scripting function to read
and assign value to the xml tag in the request xml.
To do so add Groovy Script to Test Step to the Test Suite,
once you add then your request looks as below,
Now write the Groovy/Java code to read the excel file data
and Groovy. Refer the below screen shot for the code.
Once you done with the writing
above code in your Groovy Script in the Test Step, then now its time to execute
the Groovy script. When we run the Groovy script this script will read, excel
sheet data and assigns the value to the xml respective xml tag in to the
Request xml and run or execute the “SendSMSToIndia” request.
Now its
time to read the Request’s Response xml. When we execute the “SendSMSToIndia”
request then below response is returned by the system,
In the response xml we can see ‘FromEmailAddress’ ,’MobileNumber’,
’Provider’ ,’State’, and ’Status’ are the tags which need to verify in the
response. For this need to below lines code to get value from response.
Keep these lines of code inside the for loop, why system
reads the each row till last row of the excel sheet input data and assigns to
respective tag of the request xml, and once the request executes then system
generates the response xml then above code reads the respective or required
tags from the response xml. Once you add above code to the Groovy script code
then finally script looks like below.
In short Script will read the excel sheet data as cell value (row, column), this values is as same as tag name in the request xml.
Script will read completely content of the xml and stores in
the holder. This holder will take above excel cell value to verify the tag is
exist in the xml or not, if exist then enter the value and update the xml.
Script will also execute Request for each record in excel until
the last row of excel.
Now you can use these parameters which you read from the
response xml, and update into the excel sheet just as Report.
Once you done with this then you have saved some more budget
to your organization, which you are spending on buying License every year.
With this…
That’s all Folks.