Interview Questions

How to add an Assertion to the test ?


(Continued from previous question...)

How to add an Assertion to the test ?

1. Close all windows you have open in soupUI before starting. Double Click on your Test Request as shown below. This will open the request editor.
2. In the request editor, Click the Add an Assertion to Test Request button.
3. Select Response SLA from the drop down in the Select Assertion dialog box.
4. In the Configure Response SLA Assertion dialog box, write 500 and click OK. This will validate that the response of the SLA is under 500.
5. Now that you've added the assertion, you are going to run the request to validate the response. If all assertions are successful, the SOAP icon should turn green in three places .
6. You can also validate the response by adding an XPath Match assertion.
7. In SoapUI Pro you can open the Select XPath dialog, which let's you select nodes to assert using point-and-click. As a result SoapUI creates the matching XPath expression that refers to the selected node.
8. SoapUI automatically populates the expected result to match what's in the response. But of course, you can change this to what's relevant for you.
9. Now let's try and enter the ianacode SE (for Sweden) as a request, and execute the test.
10. Oh no! The test failed! SoapUI gives us a red icon in three different places, and the Assertions-tab expands telling us that our XPath Assertion failed. This is because we said that the allregionslist should contain the US states, and we asked for the Swedish regions.
11. Change back the ianacode to US and try executing the test again. You will now see that all assertion are set to "VALID". This is because the we now get the list of US States in the response, which is what the XPath Assertion is looking for.

(Continued on next question...)

Other Interview Questions