GeekBrains
300*600
↑↑

↓↓
Флаг России Флаг Англии
🏠 | 💻 PC | 🔨Testing |

SOAP UI

Creating a Test Suit in SOAP UI Assertions in SOAP UI
XPath Match Assertion Mock Service with SOAP UI

Creating a Test Suit in SOAP UI

→Right Click on your Project

→ Create New TestSuit (CTRL + T)

→ Specify name of TestSuit

→ Right Click on your TestSuit

→ New TestCase (CTRL + N)

→ Specify name of TestCase

→ Expand Test Case

→ Click on Test Steps

→ Add Step

→ Choose request (e.g. SOAP Request)

→ Specify name for new step

→ Select operation to invoke for request

→ Add Request to TestCase (OK)


Green «+» icon will appear. By clicking it you can add Assertions.

SOAP UI New Test Suite

Specify name of TestSuite

New TestCase

Specify name of TestCase

Assertions in SOAP UI

Assertions are added to the TestSuits so to be able to add Assertions you need to create at least one TestSuit and click the green + sign.

SOAP UI assertion types

Then you can choose one of the wide variety of available assertion types.

SOAP UI assertion types

Property Content → Contains

ChooseContains. With this assertion it will be possible to search for the existence of a string token in the property value. It supports regular expressions and is applicable to any property.

Specify unique name of Assertion
SOAP UI assertion types
Type in content that you expect to receive in case of successfull request
Contains Assertion

Property Content → Not Contains

Choose Not Contains. With this assertion it will be possible to search for the non-existence of a string token in the property value. It supports regular expressions and is applicable to any property.

Specify unique name of Assertion
SOAP UI assertion types
Type in content that you definitely do not want to receive in the response
Contains Assertion

🔝

Compliance, Status and Standards

SOAP Response

Choose SOAP Response. With this assertion you can check that the last received response is a valid SOAP Response. It is applicable only to SOAP TestRequest Steps only. Do not try to use it with REST.

Double click on the Assertion. It does not require any additional parameters and can be added to the test step only once.
SOAP Request assertion

Compliance, Status and Standards

Valid HTTP Status Code

Choose Valid HTTP Status Code. With this assertion you can check that the last received response is a valid SOAP Response. It is applicable only to SOAP TestRequest Steps only. Do not try to use it with REST.

Valid HTTP Status Code assertion
Type in the HTTP Status Codes that are appropriate for your request.

Usually it is 200 but you need to read system specification to be sure.

Valid HTTP Status Code assertion

SLA → Response SLA

Choose Response SLA. With this assertion you can validate that the last received response time was within the defined limit. It is applicable to Script TestSteps And TestSteps that send requests and receive responses.

Response SLA assertion
Specify the maximum response time (ms)

If response time is not mentioned in the spec add some reasonable time.

Specify the maximum response time assertion

Property Content → XPath Match

Choose XPath Match. This Assertion uses an XPath expression to select content from the target property and compares the result to an expected value. Applicable to any property containing XML.

Click Declare

To verify that the property is present in the response type in exists (//property_name)

Type in true to the Expected Result field.

Specify XPath expression and expected result

To verify that the property is present in the response only once, type in count (//property_name)

Type in 1 to the Expected Result field.

To validate property's value put path to the propery (full path or property's name - both options are acceptable)

Type in the expected property value to the Expected Result field.

Specify XPath expression and expected result

It is possible to use XPath Assertion with multiple properties.

Type in the parent property. After you get first correct response you can click Select from current

Click Allow Wildcards

Type in * instead of actuall values in the Expected Result field.

Specify XPath expression and expected result

When, for example, we can not reach server and all our assertions are failed they will have red indicator.

SOAP UI failed assertions

Mock Service with SOAP UI

File → Create Empty Project
SOAP UI Create Empty Project
Enter Project Name
SOAP UI Enter Project Name
New Rest Mock Service
SOAP UI New Rest Mock Service
Specify name of MockService
SOAP UI Specify name of MockService
Add new mock action
SOAP UI Add new mock action
Type in Resource path and choose method GET
SOAP UI Enter Resource path
New MockResponse
SOAP UI New MockResponse
Enter name of new MockResponse
SOAP UI Enter name of new MockResponse

Copy the json below and paste it to the Response body

{
    "bicycles":{
          "bicycle": [{
          "id":1,
          "name": " Helkama ",
          "country": " Finland "
    }, {
          "id":2,
          "name": " Stels ",
          "country": "Russia"
    },{
          "id":3,
          "name": " Tunturi ",
          "country": " Finland "
       }]
    }
}

Change Content | Media type to application/json. Http Status Code should be 200 – OK. Headers are optional. You can add them by clicking green + sign.

SOAP UI Copy the json below and paste it to the Response body

Right click on BicycleService and

Add new mock action

call it «bicycle/1»

Right click on «bicycle/1» (or click Ctrl + N) and

create New MockResponse

call it «singleBicycle»

Copy the following json and paste it to the Response body

{
          "bicycle": {
          "id":1,
          "name": "Helkama ",
          "country": "Finland "
       }
}
SOAP UI new mock response

Create new mock action, keep already used name «/bicycle» but make it POST instead of GET.

Create new MockResponse and call it «addBicycle»

Copypaste the following json to body

{ "key":12041961 }
SOAP UI
Create new GET mock action «/incorrectep» and new MockResponse «400» Change Http Status Code to 400 – Bad Request
SOAP UI Http Status Code 400 - Bad Request

Notice that the Port used by BicycleService is 8080

SOAP UI Http Status Code 400 - Bad Request

Start BicycleService

SOAP UI start REST Mock service
Now we have four different mock scenarious.

Use Postman to test them.
POST to http://localhost:8080/bicycle

Should return key 12041961

SOAP UI
GET to http://localhost:8080/bicycle

Should return list of all bicycles

SOAP UI
GET to http://localhost:8080/bicycle/1

Should return one bicycle

SOAP UI
GET to http://localhost:8080/incorrectep

Should return empty body and Http Status 400 Bad Request

SOAP UI

Dynamic Response

To create dynamic response for the POST to /bicycle request replace 12041996 with ${variable} and add the following code to the script folder

context.setProperty("variable",Math.random()*100000000000000000)
SOAP UI script

To test the script go to Postman and send multiple requests

Postman request

Вы нашли то, что искали на сайте?

Или оцените по десятибальной шкале

Если сайт не помог, извиняемся за потраченное время - хочу заверить, что мы стараемся не попадать в нерелевантные запросы, но тем не менее не всегда успеваем обновлять ключевые слова. Ну и контролировать поисковую выдачу, конечно, невозможно.

Например: у нас есть статья про аэропорт Хельсинки и про аэропорт Риги но в выдаче по Риге всё равно статья про Хельсинки.

Если статья Вам помогла, нажимайте ДА. Так мы поймём, что переделывать её не нужно.

Занятно наблюдать в вебвизоре, как люди копируют текст, например вежливого отказа в трудоустройстве на английском но игнорируют кнопку ДА.

Сделаем поиск лучше!

Контакты и сотрудничество:
Рекомендую наш хостинг beget.ru
Пишите на info@urn.su если Вы:
1. Хотите написать статью для нашего сайта или перевести статью на свой родной язык.
2. Хотите разместить на сайте рекламу, подходящуюю по тематике.
3. Реклама на моём сайте имеет максимальный уровень цензуры. Если Вы увидели рекламный блок недопустимый для просмотра детьми школьного возраста, вызывающий шок или вводящий в заблуждение - пожалуйста свяжитесь с нами по электронной почте
4. Нашли на сайте ошибку, неточности, баг и т.д. ... .......
5. Статьи можно расшарить в соцсетях, нажав на иконку сети:
Mebelaero
Finn Flare