Introduction to SoapUI day 4-5
-
Upload
qualitest-group -
Category
Technology
-
view
310 -
download
4
description
Transcript of Introduction to SoapUI day 4-5
![Page 1: Introduction to SoapUI day 4-5](https://reader034.fdocuments.net/reader034/viewer/2022052301/55957ea41a28ab11038b4756/html5/thumbnails/1.jpg)
ANY QUESTIONS??
Introduction to SOAPUI
1
![Page 2: Introduction to SoapUI day 4-5](https://reader034.fdocuments.net/reader034/viewer/2022052301/55957ea41a28ab11038b4756/html5/thumbnails/2.jpg)
MORE ABOUT ASSERTIONS
Introduction to SOAPUI
2
![Page 3: Introduction to SoapUI day 4-5](https://reader034.fdocuments.net/reader034/viewer/2022052301/55957ea41a28ab11038b4756/html5/thumbnails/3.jpg)
3
![Page 4: Introduction to SoapUI day 4-5](https://reader034.fdocuments.net/reader034/viewer/2022052301/55957ea41a28ab11038b4756/html5/thumbnails/4.jpg)
Xpath Functions
4
![Page 5: Introduction to SoapUI day 4-5](https://reader034.fdocuments.net/reader034/viewer/2022052301/55957ea41a28ab11038b4756/html5/thumbnails/5.jpg)
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
![Page 6: Introduction to SoapUI day 4-5](https://reader034.fdocuments.net/reader034/viewer/2022052301/55957ea41a28ab11038b4756/html5/thumbnails/6.jpg)
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
![Page 7: Introduction to SoapUI day 4-5](https://reader034.fdocuments.net/reader034/viewer/2022052301/55957ea41a28ab11038b4756/html5/thumbnails/7.jpg)
7
![Page 8: Introduction to SoapUI day 4-5](https://reader034.fdocuments.net/reader034/viewer/2022052301/55957ea41a28ab11038b4756/html5/thumbnails/8.jpg)
Adding Assertions to Test Step
• In the response, we want to verify a successful response
8
![Page 9: Introduction to SoapUI day 4-5](https://reader034.fdocuments.net/reader034/viewer/2022052301/55957ea41a28ab11038b4756/html5/thumbnails/9.jpg)
Automatically Populates
9
![Page 10: Introduction to SoapUI day 4-5](https://reader034.fdocuments.net/reader034/viewer/2022052301/55957ea41a28ab11038b4756/html5/thumbnails/10.jpg)
Can also select for Content matching RegEx
10
![Page 11: Introduction to SoapUI day 4-5](https://reader034.fdocuments.net/reader034/viewer/2022052301/55957ea41a28ab11038b4756/html5/thumbnails/11.jpg)
Exists
11
![Page 12: Introduction to SoapUI day 4-5](https://reader034.fdocuments.net/reader034/viewer/2022052301/55957ea41a28ab11038b4756/html5/thumbnails/12.jpg)
Prepopulates XPath
12
![Page 13: Introduction to SoapUI day 4-5](https://reader034.fdocuments.net/reader034/viewer/2022052301/55957ea41a28ab11038b4756/html5/thumbnails/13.jpg)
SOAP/non SOAP response
13
![Page 14: Introduction to SoapUI day 4-5](https://reader034.fdocuments.net/reader034/viewer/2022052301/55957ea41a28ab11038b4756/html5/thumbnails/14.jpg)
SOAP fault/non-SOAP fault
14
![Page 15: Introduction to SoapUI day 4-5](https://reader034.fdocuments.net/reader034/viewer/2022052301/55957ea41a28ab11038b4756/html5/thumbnails/15.jpg)
Response SLA
15
![Page 16: Introduction to SoapUI day 4-5](https://reader034.fdocuments.net/reader034/viewer/2022052301/55957ea41a28ab11038b4756/html5/thumbnails/16.jpg)
XPath/XQuery match
16
![Page 17: Introduction to SoapUI day 4-5](https://reader034.fdocuments.net/reader034/viewer/2022052301/55957ea41a28ab11038b4756/html5/thumbnails/17.jpg)
Prepopulates
17
![Page 18: Introduction to SoapUI day 4-5](https://reader034.fdocuments.net/reader034/viewer/2022052301/55957ea41a28ab11038b4756/html5/thumbnails/18.jpg)
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
![Page 19: Introduction to SoapUI day 4-5](https://reader034.fdocuments.net/reader034/viewer/2022052301/55957ea41a28ab11038b4756/html5/thumbnails/19.jpg)
Script
19
![Page 20: Introduction to SoapUI day 4-5](https://reader034.fdocuments.net/reader034/viewer/2022052301/55957ea41a28ab11038b4756/html5/thumbnails/20.jpg)
Security Status
20
![Page 21: Introduction to SoapUI day 4-5](https://reader034.fdocuments.net/reader034/viewer/2022052301/55957ea41a28ab11038b4756/html5/thumbnails/21.jpg)
What information is sensitive?
21
![Page 22: Introduction to SoapUI day 4-5](https://reader034.fdocuments.net/reader034/viewer/2022052301/55957ea41a28ab11038b4756/html5/thumbnails/22.jpg)
Global Tokens
22
![Page 23: Introduction to SoapUI day 4-5](https://reader034.fdocuments.net/reader034/viewer/2022052301/55957ea41a28ab11038b4756/html5/thumbnails/23.jpg)
WS Addressing/Status
23
![Page 24: Introduction to SoapUI day 4-5](https://reader034.fdocuments.net/reader034/viewer/2022052301/55957ea41a28ab11038b4756/html5/thumbnails/24.jpg)
JMS status & Timeouts• Similar to the SLA Assertions
24
![Page 25: Introduction to SoapUI day 4-5](https://reader034.fdocuments.net/reader034/viewer/2022052301/55957ea41a28ab11038b4756/html5/thumbnails/25.jpg)
Multiple Content Assertions
25
![Page 26: Introduction to SoapUI day 4-5](https://reader034.fdocuments.net/reader034/viewer/2022052301/55957ea41a28ab11038b4756/html5/thumbnails/26.jpg)
Lots of Assertions!
• Just for the first step:
What if we wanted to repeat these for multiple steps?
26
![Page 27: Introduction to SoapUI day 4-5](https://reader034.fdocuments.net/reader034/viewer/2022052301/55957ea41a28ab11038b4756/html5/thumbnails/27.jpg)
Assertions at the Test Case Level
27
![Page 28: Introduction to SoapUI day 4-5](https://reader034.fdocuments.net/reader034/viewer/2022052301/55957ea41a28ab11038b4756/html5/thumbnails/28.jpg)
Grouping Assertions• Assertions in a Test Step can be grouped
28
AND: all Assertions valid = PASS
OR: at least one valid Assertion = PASS
![Page 29: Introduction to SoapUI day 4-5](https://reader034.fdocuments.net/reader034/viewer/2022052301/55957ea41a28ab11038b4756/html5/thumbnails/29.jpg)
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
![Page 30: Introduction to SoapUI day 4-5](https://reader034.fdocuments.net/reader034/viewer/2022052301/55957ea41a28ab11038b4756/html5/thumbnails/30.jpg)
Web Services with Attachments
• Often times web services have attachments associated with them
– Files (images)
– cookies
30
![Page 31: Introduction to SoapUI day 4-5](https://reader034.fdocuments.net/reader034/viewer/2022052301/55957ea41a28ab11038b4756/html5/thumbnails/31.jpg)
Send in Form
31
![Page 32: Introduction to SoapUI day 4-5](https://reader034.fdocuments.net/reader034/viewer/2022052301/55957ea41a28ab11038b4756/html5/thumbnails/32.jpg)
For the TMNG_CMS project
32
![Page 33: Introduction to SoapUI day 4-5](https://reader034.fdocuments.net/reader034/viewer/2022052301/55957ea41a28ab11038b4756/html5/thumbnails/33.jpg)
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
![Page 34: Introduction to SoapUI day 4-5](https://reader034.fdocuments.net/reader034/viewer/2022052301/55957ea41a28ab11038b4756/html5/thumbnails/34.jpg)
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
![Page 35: Introduction to SoapUI day 4-5](https://reader034.fdocuments.net/reader034/viewer/2022052301/55957ea41a28ab11038b4756/html5/thumbnails/35.jpg)
Run Test Case Test Step
35
![Page 36: Introduction to SoapUI day 4-5](https://reader034.fdocuments.net/reader034/viewer/2022052301/55957ea41a28ab11038b4756/html5/thumbnails/36.jpg)
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
![Page 37: Introduction to SoapUI day 4-5](https://reader034.fdocuments.net/reader034/viewer/2022052301/55957ea41a28ab11038b4756/html5/thumbnails/37.jpg)
Groovy Programming Language
• Language Overview
• Flow control
• SoapUI object model
• Dynamic test management
• Writing logic to verify scripts
![Page 38: Introduction to SoapUI day 4-5](https://reader034.fdocuments.net/reader034/viewer/2022052301/55957ea41a28ab11038b4756/html5/thumbnails/38.jpg)
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
![Page 39: Introduction to SoapUI day 4-5](https://reader034.fdocuments.net/reader034/viewer/2022052301/55957ea41a28ab11038b4756/html5/thumbnails/39.jpg)
Control structures
• Logic branches
• Looping
• If else
39
![Page 40: Introduction to SoapUI day 4-5](https://reader034.fdocuments.net/reader034/viewer/2022052301/55957ea41a28ab11038b4756/html5/thumbnails/40.jpg)
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
![Page 41: Introduction to SoapUI day 4-5](https://reader034.fdocuments.net/reader034/viewer/2022052301/55957ea41a28ab11038b4756/html5/thumbnails/41.jpg)
Script Editors - Tabs
41
![Page 42: Introduction to SoapUI day 4-5](https://reader034.fdocuments.net/reader034/viewer/2022052301/55957ea41a28ab11038b4756/html5/thumbnails/42.jpg)
Script Editor – Test Suite
42
![Page 43: Introduction to SoapUI day 4-5](https://reader034.fdocuments.net/reader034/viewer/2022052301/55957ea41a28ab11038b4756/html5/thumbnails/43.jpg)
Script Editor - TestCase
43
![Page 44: Introduction to SoapUI day 4-5](https://reader034.fdocuments.net/reader034/viewer/2022052301/55957ea41a28ab11038b4756/html5/thumbnails/44.jpg)
Script Editor – Test Step
44
![Page 45: Introduction to SoapUI day 4-5](https://reader034.fdocuments.net/reader034/viewer/2022052301/55957ea41a28ab11038b4756/html5/thumbnails/45.jpg)
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
![Page 46: Introduction to SoapUI day 4-5](https://reader034.fdocuments.net/reader034/viewer/2022052301/55957ea41a28ab11038b4756/html5/thumbnails/46.jpg)
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
![Page 47: Introduction to SoapUI day 4-5](https://reader034.fdocuments.net/reader034/viewer/2022052301/55957ea41a28ab11038b4756/html5/thumbnails/47.jpg)
Useful info
• Access project name
• testRunner.testCase.testSuite.project.name
• Access test step name
• context.getCurrentStep().getLabel()
47
![Page 48: Introduction to SoapUI day 4-5](https://reader034.fdocuments.net/reader034/viewer/2022052301/55957ea41a28ab11038b4756/html5/thumbnails/48.jpg)
Data Source
48
![Page 49: Introduction to SoapUI day 4-5](https://reader034.fdocuments.net/reader034/viewer/2022052301/55957ea41a28ab11038b4756/html5/thumbnails/49.jpg)
Data Sync
49
![Page 50: Introduction to SoapUI day 4-5](https://reader034.fdocuments.net/reader034/viewer/2022052301/55957ea41a28ab11038b4756/html5/thumbnails/50.jpg)
Saving Test Step Results
50
![Page 51: Introduction to SoapUI day 4-5](https://reader034.fdocuments.net/reader034/viewer/2022052301/55957ea41a28ab11038b4756/html5/thumbnails/51.jpg)
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.
![Page 52: Introduction to SoapUI day 4-5](https://reader034.fdocuments.net/reader034/viewer/2022052301/55957ea41a28ab11038b4756/html5/thumbnails/52.jpg)
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
![Page 53: Introduction to SoapUI day 4-5](https://reader034.fdocuments.net/reader034/viewer/2022052301/55957ea41a28ab11038b4756/html5/thumbnails/53.jpg)
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
![Page 54: Introduction to SoapUI day 4-5](https://reader034.fdocuments.net/reader034/viewer/2022052301/55957ea41a28ab11038b4756/html5/thumbnails/54.jpg)
Assertion with Script
54
![Page 55: Introduction to SoapUI day 4-5](https://reader034.fdocuments.net/reader034/viewer/2022052301/55957ea41a28ab11038b4756/html5/thumbnails/55.jpg)
Auto-Generates Script
55
![Page 56: Introduction to SoapUI day 4-5](https://reader034.fdocuments.net/reader034/viewer/2022052301/55957ea41a28ab11038b4756/html5/thumbnails/56.jpg)
Change to get all nodes
56
![Page 57: Introduction to SoapUI day 4-5](https://reader034.fdocuments.net/reader034/viewer/2022052301/55957ea41a28ab11038b4756/html5/thumbnails/57.jpg)
GroovyUtils
57
![Page 58: Introduction to SoapUI day 4-5](https://reader034.fdocuments.net/reader034/viewer/2022052301/55957ea41a28ab11038b4756/html5/thumbnails/58.jpg)
xmlHolder Methods
58
![Page 59: Introduction to SoapUI day 4-5](https://reader034.fdocuments.net/reader034/viewer/2022052301/55957ea41a28ab11038b4756/html5/thumbnails/59.jpg)
XQuery
59
![Page 60: Introduction to SoapUI day 4-5](https://reader034.fdocuments.net/reader034/viewer/2022052301/55957ea41a28ab11038b4756/html5/thumbnails/60.jpg)
Navigation
• // means keep going down levels
• / means go down one level
60
![Page 61: Introduction to SoapUI day 4-5](https://reader034.fdocuments.net/reader034/viewer/2022052301/55957ea41a28ab11038b4756/html5/thumbnails/61.jpg)
Max or Min
61
![Page 62: Introduction to SoapUI day 4-5](https://reader034.fdocuments.net/reader034/viewer/2022052301/55957ea41a28ab11038b4756/html5/thumbnails/62.jpg)
Count
62
![Page 63: Introduction to SoapUI day 4-5](https://reader034.fdocuments.net/reader034/viewer/2022052301/55957ea41a28ab11038b4756/html5/thumbnails/63.jpg)
ANDs/ORs
63
![Page 64: Introduction to SoapUI day 4-5](https://reader034.fdocuments.net/reader034/viewer/2022052301/55957ea41a28ab11038b4756/html5/thumbnails/64.jpg)
Useful XPath Functions
64
![Page 65: Introduction to SoapUI day 4-5](https://reader034.fdocuments.net/reader034/viewer/2022052301/55957ea41a28ab11038b4756/html5/thumbnails/65.jpg)
WSDL Refactoring
65
![Page 66: Introduction to SoapUI day 4-5](https://reader034.fdocuments.net/reader034/viewer/2022052301/55957ea41a28ab11038b4756/html5/thumbnails/66.jpg)
Connect Old & New
• Sometimes the operation names change
66
![Page 67: Introduction to SoapUI day 4-5](https://reader034.fdocuments.net/reader034/viewer/2022052301/55957ea41a28ab11038b4756/html5/thumbnails/67.jpg)
Map Nodes per Operation
• You also have the chance to manually edit
67
![Page 68: Introduction to SoapUI day 4-5](https://reader034.fdocuments.net/reader034/viewer/2022052301/55957ea41a28ab11038b4756/html5/thumbnails/68.jpg)
XPath Mapping
68
![Page 69: Introduction to SoapUI day 4-5](https://reader034.fdocuments.net/reader034/viewer/2022052301/55957ea41a28ab11038b4756/html5/thumbnails/69.jpg)
Organizing your projects• Setting up a workspace
69
![Page 70: Introduction to SoapUI day 4-5](https://reader034.fdocuments.net/reader034/viewer/2022052301/55957ea41a28ab11038b4756/html5/thumbnails/70.jpg)
Import Projects
• Import projects into the Workspace
• Easily Switch between
workspaces
70
![Page 71: Introduction to SoapUI day 4-5](https://reader034.fdocuments.net/reader034/viewer/2022052301/55957ea41a28ab11038b4756/html5/thumbnails/71.jpg)
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
![Page 72: Introduction to SoapUI day 4-5](https://reader034.fdocuments.net/reader034/viewer/2022052301/55957ea41a28ab11038b4756/html5/thumbnails/72.jpg)
Environments
• Another way to help manage your projects is to set up environments on the Project level
72
![Page 73: Introduction to SoapUI day 4-5](https://reader034.fdocuments.net/reader034/viewer/2022052301/55957ea41a28ab11038b4756/html5/thumbnails/73.jpg)
Organizing your projects• Setting up a workspace
73
![Page 74: Introduction to SoapUI day 4-5](https://reader034.fdocuments.net/reader034/viewer/2022052301/55957ea41a28ab11038b4756/html5/thumbnails/74.jpg)
Import Projects
• Import projects into the Workspace
• Easily Switch between
workspaces
74
![Page 75: Introduction to SoapUI day 4-5](https://reader034.fdocuments.net/reader034/viewer/2022052301/55957ea41a28ab11038b4756/html5/thumbnails/75.jpg)
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
![Page 76: Introduction to SoapUI day 4-5](https://reader034.fdocuments.net/reader034/viewer/2022052301/55957ea41a28ab11038b4756/html5/thumbnails/76.jpg)
Environments
• Another way to help manage your projects is to set up environments on the Project level
76
![Page 77: Introduction to SoapUI day 4-5](https://reader034.fdocuments.net/reader034/viewer/2022052301/55957ea41a28ab11038b4756/html5/thumbnails/77.jpg)
Add Name
77
![Page 78: Introduction to SoapUI day 4-5](https://reader034.fdocuments.net/reader034/viewer/2022052301/55957ea41a28ab11038b4756/html5/thumbnails/78.jpg)
Change environment specifics
78