Soap UI – Concepts and Usage Assurance Services Unit 1
Agenda Introduction to SOA Install SOAP UI Create a project in SOAP UI Create a Test Suit in SOAP UI Validation of Response Message Report generation of Test Suites 2 2
Introduction to SOA 3
What is SOA A service-oriented architecture (SOA) is an application framework that takes everyday business applications and breaks them down into individual business functions and processes, called services. SOA lets you build, deploy and integrate these services independent of applications and the computing platforms on which they run. An SOA frees service components from applications, so you can expose them to customers and partners
What is SOAP UI SOAP UI is the leading tool for Web Service Testing.It is the most commonly used tool for Service Oriented Architecture(SOA) testing. SOAP UI is free and open source and used for testing Web Services. SOAP UI is mainly used by developers for unit testing of services and testers for functional,Integration and System Integration testing. Functional and Load Testing can be done either interactively in SOAP UI or within an automated build or integration process using the SOAP UI command line tools.
Install SOAP UI 6
Install SOAP UI To get the SOAP UI Download SOAP UI from : http://www.soapui.org/index.html To check the environment variables To run the SOAP UI,there should be JAVA_HOME variable defined in your environment variables. To check the environment variable setting please follow the below steps:- 1. Go to Start menu and right-click My Computer and select Properties.The Properties window appears. 2. Click the Advanced Tab .The options in the advanced tab appear. 3. Click the Environment Variables button. JAVA_HOME variable and the value defined are listed under User variables for you to start SOAP UI. 4. If JAVA_HOME is not available in your environment variables, then click the New button in Environment Variables window.The New User Variable window appears. 5. In the New User Variable window, enter the following variable name and value in the relevant fields and then click OK. Variable name: JAVA_HOME Variable value: Path of the Java JDK (Ex. C:\java\jdk1.5.0_06) The JAVA_HOME Variable will be added to your environment.
Soap UI window is divided into the following views: Left Right The main navigator showing a hierarchy of all projects , interfaces, etc The SOAP UI desktop containing editors and viewers for those double clicked items in the navigator Selecting an item will show available overview information in the bottom left “Properties” panel. Cycle between active panes with Ctrl-Tab or use Ctrl-W to switch Double clicking or pressing enter on a selected item will open the items editor to the right if available. Maximize ,Minimize , Resize or Move as usual using each panes window menu Focusing on a pane will automatically put focus on its item in the navigator , scrolling into view if necessary
SOAP UI Window 9 9
Create a Project in SOAP UI 10
To create a project in SOAP UI A. To create a project in SOAP UI with the available WSDL URL 1. On the browser, enter the available WSDL URL Note: Opening the URL in the browser might require when you are connecting with the test environment from VPN or some other connectivity. Fig-1
2. From the address bar copy updated URL. 3. In SOAP UI, click File and then select New soapUI Project. The New soapUI Project window opens. See Figure 2. Fig-2
4. In the Initial WSDL/WADL field,paste the WSDL URL and enter the project name. Fig-3
5. Click OK A new project will be created from the given URL and will be shown in your SOAP UI window. Refer Figure -4. Fig-4
Button to send the request 6. From the project tree, click Request 1. Note: You can right-click the request and then select Rename to rename the request. The following window will open with a default request and with all the relevant attributes. There will be a ‘?’ mark in the place of the actual values. 7. Add values in the request based on your test case and hit the service by clicking the button.The response will be shown in the response window. Button to send the request Fig-5 Request Window Response Window
Based on your test cases the requests have been created. 8. Right-click the service name and select New request to create another request in the same project. Based on your test cases the requests have been created. Fig-6
B. To create a project in SOAP UI with the available WSDL and XSD files If you don’t have the WSDL URL but you have the WSDL and XSD files (such as ListAvailableProducts.wsdl,common.xsd,listavailableproductsrequest.xsd,and listavailableproductsresponse.xsd) for the respective service, perform the following steps to create a new project and test the web service: 1. Place all the XSD in a single folder and WSDL file outside the folder. Fig-7
The Open window appears. 2. In SOAP UI, click File and then select New soapUI Project,The New soapUI Project window opens. 3. In the Initial WSDL/WADL field, type the project name that you want to name and open the WSDL location by clicking the Browse button next to the Initial WSDL/WADL field. The Open window appears. Note: SOAP UI will take the path of the WDSL from the browsed location. Fig-8
4. Click OK from the New SoapUI Project dialog box. The project will be uploaded from the given location and will be shown in your SOAP UI window. Fig-9
Fig-10
5. From the Project tree, click the Request 1. You can add your request in the request window and hit the service to get the response. Fig-11
Create a Test Suit in SOAP UI 22
To create a Test Suite in SOAP UI Test suite can be used to create all the requests based on all the test cases so that you can test all the test cases simultaneously. To create a Test Suite, perform the following steps: 1. Right-click the Projects and then select New SOAP UI Project. A new project is created. 2. In the New soapUI Project, select the Create a TestSuite for the imported WSDL or WADL option. Fig-20 3. Click OK.
4. Click OK for the default values. Fig-21 5. Again, click OK for default values Fig-22
A test suite will be created by default with single test case with the ideal request with empty values as highlighted in Figure 23. Fig-23 Test Suite which will have all the test cases in it Test Step will be having collection of request By default created test case This will be having the by default created request
You can add values based on your test case and form a request. 6. Double-click the request link ‘sellProduct’ as highlighted in the following figure. A request window will open which will have the default request without the values. You can add values based on your test case and form a request. Fig-24
7. Right-click SellProductSOAP TestSuite and then select New test Case and create as many test cases as you need. Fig-25 8. In the New TestCase window, enter the test case name. Fig-26
Test cases will be created and it will be shown in your SOAP UI window 9. Click OK. Test cases will be created and it will be shown in your SOAP UI window Fig-27 10. Right-click the particular test case to create a Test request and then add all the values in the request XML generated by default based on your test case.
11. In the Add Step window, enter request name. Fig-28 11. In the Add Step window, enter request name. Fig-29 12. Click OK.
13. Again click OK with default values. Fig-30 13. Again click OK with default values. Fig-31
it you can change the values as based on your test case. A new window will open which will have the default request with empty attributes values in it you can change the values as based on your test case. Fig-32
Similarly you can create requests for all the test steps you have created in your test suite. 14. Double-click the particular test case. A new window will open. Refer Figure 33. Fig-33 15. Click the button to run the test case.The result will appear in the same window.
16. In the test log window, click the Step 1 link highlighted in Figure 34 to check the request and response. Fig-34 Request Tab Response Tab
1. Double-click the test suite SellProductSOAP TestSuite. To run the Test Suite with all the test cases, perform the following steps: 1. Double-click the test suite SellProductSOAP TestSuite. A window will open with the test case name and a status bar showing the status of the test case. Fig-35 Select to run test cases in Sequence Select to run test cases in Parallel Run button 2. Click the button to run the test cases
On the same window there are two buttons as shown in Figure 36. Run the test cases in sequence ( ): It will run all the cases one by one and stops at the case which fails. Run the test cases in parallel ( ): It will run all the test cases in parallel irrespective of failure of any test case. Run the test cases in sequence Fig-36
Running the test cases in parallel Fig-37 . All the test cases have run and results are shown
Usage of Assertions 37
1) To validate the request and response Before sending your request you can validate it and check if your request contains all the mandatory attributes with the correct form of values or not . To check and validate your request, perform the following steps: NOTE: Response can be validated in similar manner 1. In the SOAP UI, open the Request. Fig-38
2. Right-click the request window and then select the Validate. Fig-39
If your Request is incorrect an error will be thrown in the same window with the line number and description of the error. Fig-40
3. Again right-click and then select Validate. If your Request is correct an information popup will appear displaying the feedback. Fig-41
2) Add an Assertion to the test An assertion is used for validating the response in our test. There are several assertions such as: Schema Compliance, Simple Contains, Simple Not Contains, SOAP Fault, Not SOAP Fault, SOAP Response, Response SLA, XPath Match, XQuery Match, Script Assertion, WS-Security Status, WS-Addressing Response Assertion and WS-Addressing Request Assertion. 1. Double Click on Test Request. This will open the Request Editor. 2. In the request editor, Click the Add an assertion to test request button. Fig-1 3. Select Schema Compliance from the drop down in the Select Assertion Dialog. Fig-2
4. In the Configure Schema Compliance Assertion Dialog, click OK, this will validate against the schema in the WSDL imported earlier Fig-3 5. Run the request to validate the response by running the test and if the request and all assertions are successful, the SOAP Icon on the request tab should turn green, as should the SOAP Icon in the Navigator and the Assertion Header in Request Tab. Fig-4
To get more Clarity on Assertions we will add more assertion as Contains Assertion for checking the contents of a response.The Contains Assertions checks the entire response, including the XML for a string. Fig-5 1. Let's add a search for "Madrid" in the response, since we don't know how the reponse will be formatted we'll tell soapUI to look ignore cases. Fig-6 2. Save the Asssertion.
3. As we can see the assertion fails! Fig-7 4. This is to expect, we haven't created a proper request yet, as you can see above we're sending the PLaceName "?". Now let's send something that produces the expected result in the response; "Madrid". Add the text "Madrid" to the PlaceName element in the request.
5. Run the request by clicking the Run button 5. Run the request by clicking the Run button. The assertion should now be Green since the PlaceName in the response contains the Text Madrid Fig-9 Tip: If a Assertion fails, the Assertion tab will expand and show the Assertion Inspector to highlight the failed assertion.
3) To change the socket timeout Sometimes when you try to hit service even with the correct request you may get an error called ‘connection timed out’. The reasons for this error are as follows: The service is not up. Time taken to get the response from the service is long. For the solution of the first problem, you need to verify that the service is up and running but to solve the second problem perform the following steps: 1. Click File and then select Preferences. Fig-42
The SOAP UI Preferences window will open. 2. Set the Socket Timeout (Ex. Socket Timeout: 300000). You can set this as higher as possible. 3. Click OK. Fig-43
Report generation 49
Reports Generation Soap UI Pro provides three types of reports which can be generated from inside the UI at Project, Test Suite, Test Case and Load Test level: Printable Reports - Can be printed or saved as PDF, HTML, Word, RTF, Excel, etc and are fully customizable on both global and project level, allowing you to create and customize any kind of report you may require. Data Export - Allows export of underlying report-data in XML and CSV format. This is useful if you want to import report data into other tools for custom reporting or integrations. HTML Reports - Give a simplified overview of functional test results in HTML format (not available at Load Test level). Creating your first report These are the steps to create the default printable Test Suite report: Open the included Sample Project, open the Sample Simple Test Suite. Run it with the Run button in the toolbar, which should give us the following:
2. Click the Create Report button in the toolbar when the tests have finished. This gives you the following dialog allowing you to select the desired format and set corresponding options: 3. Click the OK button to generate the report. Soap UI Pro will generate and display our report as follows:
The toolbar in the export window lets us navigate the report as well as print it. We can also export it to several formats by clicking the Save button. 4. The options available in the Create Report dialog are specific to the actual report and will only be enabled if the corresponding data is available. For example in the report in our example we had neither errors nor coverage data, so both these options were disabled. 5. Let's rerun the tests with Coverage; switch to the Test Suite Coverage tab, enable coverage with the corresponding checkbox and rerun the test suite. 6. Press the "Create Report" button and select only the Coverage option; and generate the report.
Data Export : The Data Export reporting functionality in soap UI Pro lets us export the same underlying data that is used for printable reports to xml or CSV files for any kind of post-processing. When selecting the Data Export option in the Create Report dialog, the following configuration panel will be displayed: 2. The Data Sets checklist contains a list of exportable data currently available, which will vary between reporting scopes and results. Select the desired Data Set(s), the format to export to, the folder, and if a header row should be generated. Click OK, and soap UI will create the corresponding files and open the containing folder in our file manager:
JUnit-Style HTML Reports : The JUnit-Style HTML Report prompt to generate HTML reports very reminiscent of the "classic" ant/junit report reports. Select the JUnit-Style HTML Report option from the report format drop-down and specify the format and output folder: With the desired options set, the HTML report is generated into the specified folder and opened in the systems browser:
JUnit-Style HTML Reports Contd.. : Selecting a Test Suite in the bottom left frame shows an overview of the contained Test Cases and any errors that might have occurred:
Test Automation Tools * SOA Test Tools Key Test Phases Test Automation Tools * iTKO Lisa, Parasoft SOATest, Soap UI Service Simulation Testing iTKO Lisa, Parasoft SOATest, HP Service Test , SOAP UI Message Simulation Testing iTKO Lisa, Parasoft SOATest End-End Business Process Testing SOA Governance Testing iTKO Lisa, Parasoft SOATest, HP Service Test iTKO Lisa, Parasoft SOATest, soap UI Load and Performance Testing Security Testing Crosscheck SOAPSonar The listing is not a exhaustive listing of all available tools. Selection of tools should be done based on technology and SOA implementation. soap UI is an open source automation tool for web services
Thank You 57