introduction to soapui day 4-5
DESCRIPTION
A method of communicating between two devices A software function provided at a network address over the web with the service always on It has an interface described in a machine-processable format http://www.qualitestgroup.com/TRANSCRIPT
ANY QUESTIONS??
Introduction to SOAPUI
1
MORE ABOUT ASSERTIONS
Introduction to SOAPUI
2
3
Xpath Functions
4
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
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
7
Adding Assertions to Test Step
• In the response, we want to verify a successful response
8
Automatically Populates
9
Can also select for Content matching RegEx
10
Exists
11
Prepopulates XPath
12
SOAP/non SOAP response
13
SOAP fault/non-SOAP fault
14
Response SLA
15
XPath/XQuery match
16
Prepopulates
17
Exercise• Let’s go back to the GetBibDataWSDL and
using the GetAllBibDataInformationOperation, 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
Script
19
Security Status
20
What information is sensitive?
21
Global Tokens
22
WS Addressing/Status
23
JMS status & Timeouts• Similar to the SLA Assertions
24
Multiple Content Assertions
25
Lots of Assertions!
• Just for the first step:
What if we wanted to repeat these for multiple steps?
26
Assertions at the Test Case Level
27
Grouping Assertions• Assertions in a Test Step can be grouped
28
AND: all Assertions valid = PASS
OR: at least one valid Assertion = PASS
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
Web Services with Attachments
• Often times web services have attachments associated with them
– Files (images)
– cookies
30
Send in Form
31
For the TMNG_CMS project
32
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
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
Run Test Case Test Step
35
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
Groovy Programming Language
• Language Overview
• Flow control
• SoapUI object model
• Dynamic test management
• Writing logic to verify scripts
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
Control structures
• Logic branches
• Looping
• If else
39
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
Script Editors - Tabs
41
Script Editor – Test Suite
42
Script Editor - TestCase
43
Script Editor – Test Step
44
Get & Set Properties
• // get properties from testCase, testSuite and project
• def testCaseProperty = testRunner.testCase.getPropertyValue( "MyProp" )
• def testSuiteProperty = testRunner.testCase.testSuite.getPropertyValue("MyProp" )
• def projectProperty = testRunner.testCase.testSuite.project.getPropertyValue( "MyProp" )
• def globalProperty = com.eviware.soapui.SoapUI.globalProperties.getPropertyValue( "MyProp" )
• // setting values
• testRunner.testCase.setPropertyValue("MyProp", someValue ) testRunner.testCase.testSuite.setPropertyValue( "MyProp", someValue ) testRunner.testCase.testSuite.project.setPropertyValue( "MyProp", someValue ) com.eviware.soapui.SoapUI.globalProperties.setPropertyValue( "MyProp", someValue )
45
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
Useful info
• Access project name
• testRunner.testCase.testSuite.project.name
• Access test step name
• context.getCurrentStep().getLabel()
47
Data Source
48
Data Sync
49
Saving Test Step Results
50
Groovy Step
51
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.
Incrementing a Property
52
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
Groovy Exercise
53
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
Assertion with Script
54
Auto-Generates Script
55
Change to get all nodes
56
GroovyUtils
57
xmlHolder Methods
58
XQuery
59
Navigation
• // means keep going down levels
• / means go down one level
60
Max or Min
61
Count
62
ANDs/ORs
63
Useful XPath Functions
64
WSDL Refactoring
65
Connect Old & New
• Sometimes the operation names change
66
Map Nodes per Operation
• You also have the chance to manually edit
67
XPath Mapping
68
Organizing your projects• Setting up a workspace
69
Import Projects
• Import projects into the Workspace
• Easily Switch between
workspaces
70
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
Environments
• Another way to help manage your projects is to set up environments on the Project level
72
Organizing your projects• Setting up a workspace
73
Import Projects
• Import projects into the Workspace
• Easily Switch between
workspaces
74
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
Environments
• Another way to help manage your projects is to set up environments on the Project level
76
Add Name
77
Change environment specifics
78