Want Pretty Print response in soapUI – Yes or No?

Posted: April 20, 2012 in Assertion in soapUI, Properties in soapUI, soapUI, teststep
Tags: , , , , ,

This time around I’ll be sharing a problem + solution which i have faced while testing my API request/response using soapUI.

Lately, one of the teams consuming my product API has reported an issue with “Extra Spaces” coming in the response. On using the same request in soapUI i wasn’t able to reproduce the reported issue. On further investigation i found that the extra spaces in my XML response are getting adjusted due to formatted XML response [Pretty Print], which by default are turned ON.

Issue Description :

With pretty print ON (no spaces in the response) : <myTag>Value1</myTag>
With pretty print OFF (obsereve the extra spaces in tag value) : <myTag> Value1 </myTag>

Now if one puts a contains assertion to verify the value of node, that would be something like :


However, if an individual is getting the API response using some other tool or by calling in-house developed application then this would result into a failure for them.

Reason : The actual response will always come with Pretty Print OFF (until unless handled by client tool). So now if the contains assertion (or search function) would look for the above tag+data [ ‘myTag>Value1 </myTag’ ].

So what to do? Well, i turned OFF Pretty Print for my teststep (using teststep property – PrettyPrint). Then added 2 generic contains assertion which would fail if there are any extra spaces between the tags and value. Done!

Contains Assertion 1 – Start space :  (read it as start tag symbol followed by a space – add without Square braces)
[> ]

Contains Assertion 2 – End space : (read it as space followed by 2 symbols for closing tag – add without Square braces)
[ </]

Now, NO extra spaces will appear in my response. Till next blog keep reading & keep sharing.

P.S. : The pretty print property is available at individual teststep level and can be turned on/off for a teststep. Also, using preferences [WSDL setting] this can be turned on/off for all the projects in one shot.

Disclaimer : These extra spaces appear based on the data returned from your DB Stored Proc. If these are handled properly then you will not observe any spaces in the response (with both cases).

  1. tarimanga says:

    Ciao Pradeep, interesting about PrettyPrint options, but to solve your issue wouldn’t have been simplier an XPath assertion?
    Hope this helps!

    • Hi,

      Well not exactly. Xpath would provide the value of a node and would be specific to asserted node.
      Now in my case, i was trying to find out all the nodes which contains an ‘Extra space’ in node value. And xpath won’t be of any help here 🙂

      {Pradeep Bishnoi}

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 )

Google+ photo

You are commenting using your Google+ 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