Basic Assertions in SoapUI

1. Contains:
Search for the existence of a String in the Response Value. Applicable for JSON/XML reponses.

Assertion1

For Example if your response JSON is

"Success": true,
   "AUTH":    {
      "UserId": "linkeshkannavelu",
      "TimeStampUtc": "2014-04-22T07:25:05.0077957Z",
      "SignedAs": "4Rfc0/test/Vcpk="
   }

and you are looking for the string linkeshkannavelu in the response, then you can enter the string in the Assertion Window.

Assertion2

2. XPath Match:
Traverse the XML response and return the value presents in the specific XML Node and then compares it with the expected value given.
Applicable only to property in XML Format.

Assertion3

For Example, in the last post we have verified the title of the site http://linkeshkananvelu.com.
If the returned response is

<html>
	<head>
		<body>
			<title>Keep Software Testing Weird</title>
		</body>
	</head>
</html>

You can check the title of the page by using the following Xpath.

Assertion4

3. Not Contains
Search for the non existence of a String in the Response Value. Applicable for JSON/XML reponses.

Assertion5

For Example if your response JSON is

"Success": true,
   "AUTH":    {
      "UserId": "linkeshkannavelu",
      "TimeStampUtc": "2014-04-22T07:25:05.0077957Z",
      "SignedAs": "4Rfc0/test/Vcpk="
   }

and you are looking for the string TestUsername to be not present in the response, then you can enter the string in the Assertion Window.

Assertion6

If the String exists in the response, then the test will fail.

4. Valid HTTP Status Codes:
In the reponse, usually we will get a HTTP Status Code. We can assert these response codes also.

Assertion7

For example, if you are checking that your response message got the code HTTP Status 200, then you can assert the code by

Assertion8

5. Invalid HTTP Status Codes:
This is similar to Not Contains. If the HTTP Status Code that we are receiving Should not contain the list of Codes, then we can check those assertions using this.

Assertion9

For example, if you are checking that your response message should not have the code HTTP Status 401 and 404, then you can assert the response code by

Assertion10

These are the frequently used assertions in SoapUI.

Advertisement

2 thoughts on “Basic Assertions in SoapUI

  1. Linkesh Kanna Velu Post author

    It should have that Option in SoapUI. .I am using the latest version. Click on file and you should get the “New Rest Project” option.Or else you can also proceed with “New Generic Project” to create http requests.

    Like

  2. selva

    if Soap UI not having “new rest project ” option then how to create a project instead
    of this steps.

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s