Search This Blog

Monday, November 17, 2014

Assertions in SoapUI

Assertions in SoapUI are only applicable to test requests under test steps.We put assertions to understand the behavior of tests.Tests generally passes or fails depending upon the test(having assertion point) that we have defined.Assertions are of many types in SoapUI. I'll be discussing few common assertions here.
SoapUI has the below list of assertions:
  • Property Content
    • Contains
    • Not Contains
    • Xpath Match
    • XQuery Match
  • Compliance,Status and Standards
    • Invalid HTTP Status Codes
    • Schema Compliance
    • Valid HTTP Status Codes

Contains

This assertion ensures that the parsed string is a substring of the response token received.Below is the sample response on which most of the assertions will be discussed.

 <Response xmlns="http://localhost/rest-assured-example/service/single-user">  
   <email>test@hascode.com</email>  
   <firstName>Tim</firstName>  
   <id>1</id>  
   <lastName>Testerman</lastName>  
 </Response>  

Contains assertion takes 2 types of input:
  • String
  • Regex Pattern
String be defined below:














Contains assertion with RegEx:



Not Contains

This too used in the same way we used Contains assertion.

Xpath Match

User needs to define namespace in order to form an xpath.Namespace is nothing but the reference to the parent node.

Xquery Match

Xquery match is applicable to only xml responses.Its as similar as Xpath.Find the sample assertion below:





















Hope it helps :)

No comments:

Post a Comment