top of page
  • Writer's picturekhyati sehgal

SoapUI Tutorial Part 3 : Deep dive assertions in SoapUI

Validation is way too important than Invention, I hope you agree with this statement as not only testers, business analysts, product owners believe in this statement but developers, customers are also getting inclined with the same thought. The idea is to showcase the importance of change in the perception of a developer with a QA. In this write-up, I will share how can we add verification’s in our SoapUI tests.

Why assertions are required, At All?

Rarely, it is seen that the one who is making any stuff has similar thinking with the one whose job is to find issues in that particular piece of work done. And this is al-right and very normal. Similarly, to get a job done right we need to make some validations over the tests which we used to write to test SUT(System Under Test). Assertions are used to put some checks over tests, for which we know the result prior to the run. They are used to check the relevant points such that we can take care of all positive and negative scenarios in one go.

Positive Assertions

These are the happy test assertions like for any web service response should be HTTP response 200 OK, so we can test for the string ‘200 OK’. And is a positive assertion.

Negative Assertions

For the same example above, we know that the same service in the same module should not contain HTTP response 404, or 400. So in these scenarios, we can apply Not Contains kind of assertions.

How to add assertions in SoapUI?

Well, that’s fine, but the point is to apply these assertions in SoapUI. soapui provides very cool steps to apply assertions in Test Requests and Test cases. So in SoapUi, you can add assertions in multiple ways: 1. You can add an assertion as a separate test step in the test case. * Just right-click on the test case and click on ‘Insert Step‘. * You will get an option of ‘Assertion TestStep‘, select this option for creating a new assertion as a new test step. 2. You can add assertions in a test step. * Click on a test step. On the editor view, in the button select the highlighted icon. * You will get a pop-up that allows you to add new assertion by clicking on ‘Add Assertion’ within the test step selected.

What types of assertions are there in SoapUI?

SoapUI offers various types of assertions, you can get various assertion when you click on Add Assertion icon. Highlighted assertions are the ones that you can use in test steps like SOAP, REST, MOCK, etc.

And the one’s which are not highlighted and enabled can only be used in DB related steps like JDBC

To add them to your tests, you need to click on the type of assertion you want to add. And you are DONE!

Let’s try adding an assertion in a test step:

  1. WSDL: http://www.webservicex.net/geoipservice.asmx?WSDL

  2. Project Name : geoipservice

  3. Interfaces provided: GeoIPServices.

Let’s make a new Test Suite first, by right-clicking on the project.

Make a new Test case, by right-clicking on the test suite.

Now, add a Test Request of SOAP type. And once done, double click on the test step, so that we can see the request just made in the editor view.

Next, click on the assertion tab present below the test request area( highlighted in the above image ).

Select an option from the list for example,

  1. Property Transfer: It provides various types of assertions which are for text matches like contains, not contain, XPath match, etc.

  2. Compliance, status, standards: These are more into HTTP codes, responses, So if you want to validate status codes you can use these assertions.

  3. Script: These are the widely used assertions where-in you can add your custom assertions in groovy.

  4. SLA:  It checks the time, responsiveness of responses coming from requests.

  5. JMS: These are basically used to check the response of Java Messages Services(JMS), their status, etc.

And that’s all, we are done. You see this is that much simple. I enjoyed using SoapUi for adding assertions in test cases, you can also try the same and we can talk over any query or issue you will encounter while execution.

Till then, stay tuned.

0 views0 comments
bottom of page