74
ANY QUESTIONS?? Introduction to SOAPUI 1

Soap UI - Lesson45

Embed Size (px)

DESCRIPTION

Lesson 4 & 5 http://www.qualitestgroup.com/

Citation preview

Page 1: Soap UI - Lesson45

ANY QUESTIONS??

Introduction to SOAPUI

1

Page 2: Soap UI - Lesson45

MORE ABOUT ASSERTIONS

Introduction to SOAPUI

2

Page 3: Soap UI - Lesson45

3

Page 4: Soap UI - Lesson45

Xpath Functions

4

Page 5: Soap UI - Lesson45

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: Soap UI - Lesson45

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: Soap UI - Lesson45

7

Page 8: Soap UI - Lesson45

Adding Assertions to Test Step

• In the response, we want to verify a successful response

8

Page 9: Soap UI - Lesson45

Automatically Populates

9

Page 10: Soap UI - Lesson45

Can also select for Content matching RegEx

10

Page 11: Soap UI - Lesson45

Exists

11

Page 12: Soap UI - Lesson45

Prepopulates XPath

12

Page 13: Soap UI - Lesson45

SOAP/non SOAP response

13

Page 14: Soap UI - Lesson45

SOAP fault/non-SOAP fault

14

Page 15: Soap UI - Lesson45

Response SLA

15

Page 16: Soap UI - Lesson45

XPath/XQuery match

16

Page 17: Soap UI - Lesson45

Prepopulates

17

Page 18: Soap UI - Lesson45

Script

18

Page 19: Soap UI - Lesson45

Security Status

19

Page 20: Soap UI - Lesson45

What information is sensitive?

20

Page 21: Soap UI - Lesson45

Global Tokens

21

Page 22: Soap UI - Lesson45

WS Addressing/Status

22

Page 23: Soap UI - Lesson45

JMS status & Timeouts• Similar to the SLA Assertions

23

Page 24: Soap UI - Lesson45

Multiple Content Assertions

24

Page 25: Soap UI - Lesson45

Lots of Assertions!

• Just for the first step:

What if we wanted to repeat these for multiple steps?

25

Page 26: Soap UI - Lesson45

Assertions at the Test Case Level

26

Page 27: Soap UI - Lesson45

Grouping Assertions• Assertions in a Test Step can be grouped

27

AND: all Assertions valid = PASS

OR: at least one valid Assertion = PASS

Page 28: Soap UI - Lesson45

Web Services with Attachments

• Often times web services have attachments associated with them

– Files (images)

– cookies

28

Page 29: Soap UI - Lesson45

Send in Form

29

Page 30: Soap UI - Lesson45

For the TMNG_CMS project

30

Page 31: Soap UI - Lesson45

Run Test Case Test Step

31

Page 32: Soap UI - Lesson45

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 33: Soap UI - Lesson45

Groovy Programming Language

• Language Overview

• Flow control

• SoapUI object model

• Dynamic test management

• Writing logic to verify scripts

Page 34: Soap UI - Lesson45

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

34

Page 35: Soap UI - Lesson45

Control structures

• Logic branches

• Looping

• If else

35

Page 36: Soap UI - Lesson45

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

36

Page 37: Soap UI - Lesson45

Script Editors - Tabs

37

Page 38: Soap UI - Lesson45

Script Editor – Test Suite

38

Page 39: Soap UI - Lesson45

Script Editor - TestCase

39

Page 40: Soap UI - Lesson45

Script Editor – Test Step

40

Page 41: Soap UI - Lesson45

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 )

41

Page 42: Soap UI - Lesson45

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" )

42

Page 43: Soap UI - Lesson45

Useful info

• Access project name

• testRunner.testCase.testSuite.project.name

• Access test step name

• context.getCurrentStep().getLabel()

43

Page 44: Soap UI - Lesson45

Data Source

44

Page 45: Soap UI - Lesson45

Data Sync

45

Page 46: Soap UI - Lesson45

Saving Test Step Results

46

Page 47: Soap UI - Lesson45

Groovy Step

47

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 48: Soap UI - Lesson45

Incrementing a Property

48

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 49: Soap UI - Lesson45

Groovy Exercise

49

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 50: Soap UI - Lesson45

Assertion with Script

50

Page 51: Soap UI - Lesson45

Auto-Generates Script

51

Page 52: Soap UI - Lesson45

Change to get all nodes

52

Page 53: Soap UI - Lesson45

GroovyUtils

53

Page 54: Soap UI - Lesson45

xmlHolder Methods

54

Page 55: Soap UI - Lesson45

XQuery

55

Page 56: Soap UI - Lesson45

Navigation

• // means keep going down levels

• / means go down one level

56

Page 57: Soap UI - Lesson45

Max or Min

57

Page 58: Soap UI - Lesson45

Count

58

Page 59: Soap UI - Lesson45

ANDs/ORs

59

Page 60: Soap UI - Lesson45

Useful XPath Functions

60

Page 61: Soap UI - Lesson45

WSDL Refactoring

61

Page 62: Soap UI - Lesson45

Connect Old & New

• Sometimes the operation names change

62

Page 63: Soap UI - Lesson45

Map Nodes per Operation

• You also have the chance to manually edit

63

Page 64: Soap UI - Lesson45

XPath Mapping

64

Page 65: Soap UI - Lesson45

Organizing your projects• Setting up a workspace

65

Page 66: Soap UI - Lesson45

Import Projects

• Import projects into the Workspace

• Easily Switch between

workspaces

66

Page 67: Soap UI - Lesson45

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

67

Page 68: Soap UI - Lesson45

Environments

• Another way to help manage your projects is to set up environments on the Project level

68

Page 69: Soap UI - Lesson45

Organizing your projects• Setting up a workspace

69

Page 70: Soap UI - Lesson45

Import Projects

• Import projects into the Workspace

• Easily Switch between

workspaces

70

Page 71: Soap UI - Lesson45

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: Soap UI - Lesson45

Environments

• Another way to help manage your projects is to set up environments on the Project level

72

Page 73: Soap UI - Lesson45

Add Name

73

Page 74: Soap UI - Lesson45

Change environment specifics

74