This document provides an introduction to SOAPUI, including how to add different types of assertions to test steps to validate responses. It discusses contains/not contains assertions, SOAP/non-SOAP requests, faults, response time limits, XPath matching, and more. It also covers using Groovy scripts to manipulate tests and responses, refactoring WSDLs, and organizing projects using workspaces and environments.
5. Adding Assertions
• CONTAINS/NOT CONTAINS
• SOAP/Non SOAP Reqest
• SOAP fault/non-SOAP fault
• Response SLA
• Xpath/Xquery match
• Script
• Security status
• JMS status and timeouts
5
6. CONTAINS/Not CONTAINS
• Contains checks for the existence of some
text in the received response or request
message
• Not Contains - Searches for the non-existence
of a string token in the property value,
supports regular expressions. Applicable to
any property.
6
18. Exercise
• Let’s go back to the GetBibDataWSDL and
using the GetAllBibDataInformation
Operation, add the following assertions in the
response:
• CONTAINS an application number
• Valid SOAP request
• No SOAP Fault
• Response SLA < 5 sec
• Xpath match on all of the authors (hint – use
the string-join function) 18
28. Grouping Assertions
• Assertions in a Test Step can be grouped
28
AND: all Assertions valid = PASS
OR: at least one valid Assertion = PASS
29. Exercise
• Create a Test Suite For the REST service for
CUSTOMERS
• Add a data source with customer numbers 1-
10 and a data loop
• Add an assertion step that contains an
assertion for
– No SOAP fault
– SLA of .5 sec
– Customer name exists
29
30. Web Services with Attachments
• Often times web services have attachments
associated with them
– Files (images)
– cookies
30
33. Exercise
• Using TMNG_CMS project create a new Test
Suite
• Use the image file provided
• Use the copy of the updated payload as
provided
• Create a request that contains the image to be
uploaded
33
34. Exercise (cnt)
• Create an excel data source that has the file
names for the image
• Set up a property for the serial number
• Set up a test case that creates the image and
then updates it
• Verify that the version of the image is
incremented on the update
• Use a datasink to capture the image version
34
36. Let’s Get Groovy
• Groovy Programming Language
• Exercise – writing groovy scripts
• Refactoring
• Exercise – refactoring wsdl
• Web Services with attachments
• Exercise – configure and test web service with attachment
37. Groovy Programming Language
• Language Overview
• Flow control
• SoapUI object model
• Dynamic test management
• Writing logic to verify scripts
38. Language Overview
• Groovy is the scripting language used in
SoapUI for controlling tests
• Groovy is also a programming language that
can run stand-alone in a java environment
– Contains some data structures similar to java
• Lists (like java arrays)
• Maps
38
40. Groovy Script Usage
• Groovy Script TestStep in a TestCase
• Before and after running a TestCase or
TestSuite to initialize or cleanup
• Starting/Stopping MockService
• Initialize/Cleanup Project level
• Dynamic DataSource or DataSync
• Creating dynamic MockResponse content
• Adding Script Assertions
40
46. Get & Set Settings
• import com.eviware.soapui.settings.SSLSettings
• import com.eviware.soapui.SoapUI
• // set SoapUI.settings.setString( SSLSettings.KEYSTORE, pathToKeystore )
SoapUI.settings.setString( SSLSettings.KEYSTORE_PASSWORD,
keystorePassword )
• // get SoapUI.settings.getString( SSLSettings.KEYSTORE, "value to return if
there is no such setting set" )
46
47. Useful info
• Access project name
• testRunner.testCase.testSuite.project.name
• Access test step name
• context.getCurrentStep().getLabel()
47
51. Groovy Step
You can add a Groovy step by right clicking on a test
step and selecting “Insert Step” followed by “Groovy
Script” or by opening the TestCase and clicking on the
star icon.
51
52. Incrementing a Property
Here’s how to increment a property called PatentNum.
• Get the TestCase Property (as a “BigDecimal”)
• Increment the value
• Set the value back into the property
def old = context.testCase.getPropertyValue(“PatentNum") as BigDecimal;
def new = (old+ 1) as String;
context.testCase.setPropertyValue( “PatentNum", new );
Notice how the setPropertyValue differs from the
getPropertyValue
52
53. Groovy Exercise
In this exercise we will:
• Set up a Test Case property
• Read a number in from a text file
• Transfer the number to a property
• Execute a request using the property
• Increment the property
• Store the property back to the text file
53
70. Import Projects
• Import projects into the Workspace
• Easily Switch between
workspaces
70
71. Workspaces
• Can only have one workspace open at a time
• Same project can be in two workspaces
• Can have multiple projects loaded into
workspace
• Can’t have separate projects and workspaces
loaded at the same time
71
72. Environments
• Another way to help manage your projects is
to set up environments on the Project level
72
74. Import Projects
• Import projects into the Workspace
• Easily Switch between
workspaces
74
75. Workspaces
• Can only have one workspace open at a time
• Same project can be in two workspaces
• Can have multiple projects loaded into
workspace
• Can’t have separate projects and workspaces
loaded at the same time
75
76. Environments
• Another way to help manage your projects is
to set up environments on the Project level
76
When updating a WSDL, the underlying contract changes may require changes to all messages related to a certain modification, for example if an element has been renamed or moved. Also, XPath expressions in assertions, property transfers and expansions, etc. may need to be updated to correctly reference updated elements. Right-click on the wsdl definition and select refactor definition. Always, always create a back up before you overwrite everything
Click next after mapping all of the nodes and then review and accept any changes to the XPath
all visible projects are part of the current workspace. You can add as many projects as you want to a workspace, but can also easily switch between different workspaces allowing you to have different testing setups (for different systems, clients, etc), It can also help manage different releases for the same project. Select File > New Workspace and then enter a name