SoapUI is a simple and practical open source Web Service testing tool that provides both desktop applications and IDE plug-in programs. The ability to quickly build projects and organize test cases is a major feature of the tool, and the following examples show if you use SOAPUI for Web Service unit testing.
L Build Projects
The project in the SoapUI tool is made up of one or more Web services, where we use the Chinese TV trailer Web service:
HTTP://WWW.WEBXML.COM.CN/WEBSERVICES/CHINATVPROGRAMWEBSERVICE.ASMX?WSDL "For example, create a new WSDL project. Click File è New wsdl project , Enter the project name "CHINATV", initial WSDL "
Http://www.webxml.com.cn/webservices/ChinaTVprogramWebService.asmx?wsdl ", 1:
Where WSDL can be either a URL or a static file of WSDL.
L operation of a single service request
The SoapUI tool parses the WSDL file to get the service interface and creates the request. 2, 3: The service provides 8 interfaces, and provides two different versions depending on the version of SOAP.
Expand the SOAP request "request1 " of the Interface "gettvstationdataset ":
Double-click to view the requested SOAP message: 4
What we see is the service Request SOAP message, where the "? "The question mark represents the entry, modify it to the request parameter value"-1 "(In this instance, 1 for the Central TV), and then click the icon button to run, get the request result: 5
We see the SOAP message returned and the data in it.
L Build Test Cases
Select Project "CHINATV" and right-click, choose New TestSuite , build a test suite 6
Then, right-click in Testsuite, select New TestCase , create a new TestCase and add the service request to TestCase: 7
In this way, we have the first test case: 8
Because the service request entry is already set up in the procedure above, we double click TestCase 1 Click to run directly: 9
We see the "Green bar", which means running through.
L Increase the checkpoint.
, open service Request gettvstationdataset–request 1 , click, add Checkpoint: 10
There are several types of checkpoints, and here we choose to include "Contains " and enter the check content "CCTV": 11
We run a service request Gettvstationdataset–request 1 : 12
You can see that the checkpoint is valid:contains-valid .
L organize test steps
Getareadataset (List of supported provinces, cities and categories), Gettvstationdataset (get a list of stations by city or city ID or classified TV ID), Gettvchanneldataset (via TV station ID Get the channel list), Gettvprogramdataset (Get the Channel program list by Channel ID), add to the test step of TestCase 1, then organize the test steps to get a list of "CCTV-1" programs.
Test steps:
1. Get "Central TV" category ID "1"
2. Get "CCTV" ID in "Central TV" Category: "39"
3, access to "CCTV" channel "CCTV-1" ID: "606"
4. Get the program list of "CCTV-1" channel 13
We need to Getareadataset the "Central TV" ID "1" in the result of the service request as a service request Gettvstationdataset , right-click Getareadataset-request 1 , select Insert Step èpropertyTransfer , 14:
This property Transfer is used for the interaction between the two service requests, and we name it: "Areatransferstation" 15
Source we choose getareadataset-request 1 response, Target we choose gettvstationdataset-request 1 Request, The service request is passed to the service request Getareadataset The value of the node (Arealist[4]) in the returned result SOAP message (areaid[1]) through a script selection Gettvstationdataset As the value of the entry parameter (Theareaid[1]).
Including: Declare namespace diffgr=
"Urn:schemas-microsoft-com:xml-diffgram-v1"; Used to declare a namespace that corresponds to a namespace in a SOAP message. 16
The same procedure, we organized a number of other service requests between the interaction, the organization completed a complete test steps, finally we run testcase, see all the results: (green means running through) 17
Note: SOAPUI official website http://www.soapui.org/
"Go" Web Service Unit Test Tool example Introduction SOAPUI