As most of you all know report plays major role in any of the project, as business giant he don’t dig into and look he just look for end result i.e. Report. To generate the Excel report from SoapUI you need to just follow the below steps as i mentioned.
Create Test Data for SendSMSToIndia request as follows. [Here I have taken SendSMS WebServices for example. (http://www.webservicex.net/SendSMS.asmx?WSDL)]
As all of you know how to do Data Driven testing as i mentioned in my previous blog. In the same way you have to create Test data in excel file.
Once you are ready with Test Data creation, then create one more excel file as follows for DataSink Report.
Here I have created the sample Report format as shown in the below screen shot. I have given Sheet name as “SendSMSReport” and saved it in the local system Driver with the name as Report_SendSMSToIndia.xls, here one more important note is while saving the excel file after creating the test data we should save as “.xls”and SoapUI is not support any other format other than .xls.
Now it’s time to create SoapUI project in SoapUI Pro tool as shown in below,
Make sure you have created the project and added the Request to Test Suite, to Test Case, to Test Step and DataSource, DataSink, Groovy Script and DataSource Loop should be as shown in below screen shots.
Now add Data Sink to the Test Step as shown in the below screenshot. To add Right Click on the Test Step and Select Add Step then select DataSink option.
Now the DataSink step will be added to your Test Step as show in below Screen Shot.
In the same way Add Groovy Step to the Test Steps which is used to validate or verify our expected result with actual result and same result can be used to update in DataSink.
In below screen shot you can see the hierarchy of the Test Steps, make sure in your project should be in the same hierarchy as same as below.
DataSource:- Is Use to reads test data from external source(Excel, File, GRID, XML, Database) into properties of request or can be used for validation.
DataSource Loop:- Is Use to loop or iterate the DataSource till the last row. Here we have select the DataSource and target step where we have to provide our input data.[will be explain in below section].
DataSink:- Is used to write Number of propertied to the External source.
GroovyScript:- Is used to write specific script for validation.
Now Open the DataSink by double clicking on it or just Right click and select open editor you will see below DataSink editor. There you can see DataSink with Dropdown list in the screenshot.
Now click on the Dropdown button. You will see list of Option to generate the report in different format.
In that select Excel Option from the list to generate the report in the Excel format as you created the sample format above. Once you select the Excel option you will see below screenshot.
In above Screenshot you can see File, Out File, Worksheet and Start at Cell with (Re)Generate Properties with One green button. Here all the fields are explained below.
File :- This is the file where which imports the sample format which we created above.
Out File :- This file is used to Update our results or reports from Datasink and stores into the specified file at under given path.
Worksheet :- The worksheet name of the file to export the result
Start at Cell :- From which Cell you want to export the result.
Change the Option Start at Cell Default value from ‘A1’ to ‘A2’ because in our excel sheet cell A1 is our headings and our actual report updates starts from cell A2 hence it should be A2.
Now To import al the headers which are created in excel file to DataSink properties click on the browse button locate the Excel file path which you created above, do it same for File and Out File, once you located you will see as same as below screenshot.
Now click on the ‘Green’ button (Re)Generate Properties:. Once you click on this button you will one more popup window named ‘Manage properties’ as shown in below screenshot.
In the Insert row number: enter value as 1(one) because in our excel file we have just created on row that too header so we have to give as 1 only. Now click on ‘OK’ button.
Now you will see in DataSink left pane editor all the headers we have created in the excel file are automatically created see below screen shot for more.
And also see the same property names are displaying in the below section in above screenshot.
Now Open the Groovy Script by double clicking on it or just Right click and select open editor you will see below Groovy Script editor. Here you can retrieve the data from any of the test step within the Test Case or from Projects and also from Other Test Suite and Test Cases with some limitations we will discuss this topic later.
Now follow the steps below to retrieve the data or result or value from the DataSource, From Response received for request.
Step 1:- Right Click on the Groovy Script Editor,
Step 2:- Goto Get Data click on DataSource select the property name which you want to compare with the actual result, here i am comparing the Actual and expected Status of the message.
Once you select the Expected_Status property then you will see one popup as below, click ok or you can provide your own name or just click ok.
Then SoapUI will generate code for as in below screen shot.
Now select the value from the response as you selected property value for DataSource.
Follow the steps..
Again right click on the Groovy Script editor as shown in below screenshot and goto
“SendSMSToIndia - Request” click on it and click on Property[Response].
Now will see one more Select XPath window there you can see response which has all the fields, in that select the required field and click on OK.
Then you will see popup as shown in below screen shot click on, then SoapUI will generate code for you as shown in below screenshot,
Now write ‘IF.. Else’ condition to compare the two Actual and expected status value. If you know java little bit then you can write it, for those who don’t know here it is.
Now moving to Data Sink above you have created Data Sink step and also added excel report
format. Now associate the values from Data Source, from Response or from Groovy Script result.
Follow the steps below,
Open the Data Sink editor you can at right hand side of the pane four properties as
TC.No :- The test case number we are taking it from the DataSource step property name ‘TC.No’
Expected Result :- Expected Result we are taking it from the DataSource step property name
Actual Result :- Actual result we are taking from the Step ‘SendSMSToIndia - Request 1’ as we
taken value in Groovy Script in same way.
Test Result :- Test result we are taking it from the Groovy Script result.
For more detailed follow the steps,
For TC.No = Right click and follow the Screen shot.
For Expected Result = Right click and follow the Screen shot.
For Actual Result = Right click and follow the Screen shot.
Click OK once you selected the required field.
For Test Result = Right click and follow the Screen shot.
Now all set to run the Test Case for all the test data in the DataSource to generate the Report in excel format. Running the Test case you have to open the Test Case Running window you can double click on the Test Case or Right click and select ‘Show Test Case Editor’ option from the menu.
And one more important note is the steps in the Test Steps should be in the same arrangement. Like DataSource should be at first Step and Request in Second, Groovy Script and Data Sink and DataSource Loop should be always last.
Once execution start you can see the logs in Test Case Log pane ate below and a gree bar with “Finished”message at the top indicates test case execution completed for the all the rows in the DataSource and also Report is also generated in the path specified for Outfile.
The report will be looks like as below Screenshot.
Now you are ready with custom report.
That’s all Folks.