SoapUI - Assertions



Assertion can be interpreted as a checkpoint or a validation point. Once a request is sent to a web server, a response is received. It is required to validate the response which contains the data as expected or not. In order to validate the response, SoapUI has an assertions feature.

Points to Note

  • Assertions are used to validate the message received by a TestStep during execution.

  • It compares the part of the message or the entire message to some expected value.

  • Any number of assertions can be added to a TestStep, each validating some different aspect and content of the response message.

  • After a TestStep executes, all its assertions are applied to the received response and if any of them fail the TestStep is marked as failed in the TestCase view.

  • Failed entry shows in the test execution log.

Execution Log

Type of Assertions

SoapUI supports a wide range of assertions in response.

Following are the list of assertions supported by SoapUI.

Assertion Description
Property Content
Contains Checks for the existence of the specified string. It also supports regular expression.
Not Contains Checks for the non-existence of the specified string. It also supports regular expression.
XPath Match Uses XPath expression to select the target node and its values. Compares the result of an XPath expression to an expected value.
XQuery Match Uses an Xquery expression to select the content from the target property. Compares the result of an XQuery expression to an expected value.
Compliance, Status, Standards
HTTP DOwnload All Resource Downloads all resources referred to be an HTML document (images, scripts, etc.) and validates that they are all available. Applicable to any property containing HTML.
Invalid HTTP Status Codes Checks that the target TestStep received an HTTP result with a status code not in the list of defined codes. Applicable to any TestStep that receives HTTP messages.
Not SOAP Fault Validates that the last received message is not a SOAP Fault. Applicable to SOAP TestSteps.
Schema Compliance Validates that the last received message is compliant with the associated WSDL or WADL schema definition. Applicable to SOAP and REST Test Steps. The schema definition URL supports Property Expansions (e.g. ${#System#my.wsdl.endpoint}/services/PortType? wsdl).
SOAP Fault Validates that the last received message is a SOAP Fault. Applicable to SOAP TestSteps SOAP Request - validates that the last received request is a valid SOAP Request. Applicable to MockResponse Test Steps only.
SOAP Response Validates that the last received response is a valid SOAP Response. Applicable to SOAP TestRequest Steps only.
Valid HTTP Status Codes Checks that the target TestStep received an HTTP result with a status code in the list of defined codes. Applicable to any TestStep that receives HTTP messages.
WS-Addressing Request Validates that the last received request contains valid WS-Addressing Headers. Applicable to MockResponse TestSteps only.
WS-Addressing Response Validates that the last received response contains valid WS-Addressing Headers. Applicable to SOAP TestRequest Steps only.
WS-Security Status Validates that the last received message contained valid WS-Security headers. Applicable to SOAP Test Steps.
Script
Script Assertion Allows the users to execute a custom script to perform user-defined validations. Applicable to TestSteps only (i.e. not properties)
SLA
Response SLA Validates if the response time of the last received response was within the defined limit. Applicable to Script TestSteps and TestSteps that send requests and receive responses.
JMS
JMS Status Validates that the JMS request of the target TestStep is executed successfully. Applicable to Request TestSteps with a JMS endpoint.
JMS Timeout Validates that the JMS statement of the target TestStep did not take longer than the specified duration. Applicable to Request TestSteps with a JMS endpoint.
Security
Sensitive Information Exposure Verifies if the response message does not expose sensitive information about the target system. We can use this assertion for REST, SOAP and HTTP TestSteps.
JDBC
JDBC Status Validates that the JDBC request of the target TestStep executed successfully. Applicable to JDBC TestSteps only.
JDBC Timeout Validates that the JDBC statement of the target TestStep did not take longer than the specified duration. Applicable to JDBC TestSteps only.
Advertisements