Pretty Printing in SOAPUI

By default, SOAPUI will pretty-print responses it receives back from web services calls. This is all well and good; makes things simpler to interpret for humans. Unfortunately, it also uses the pretty-printed XML to evaluate any XPATH assertions on your test steps. This means that if the responses contain leading and/or trailing spaces, they are removed. Thus,

 25    

becomes

25

. By itself, this is not a problem. In fact, it’s convenient. It’s easier to assert that

//requestId='25'

than

normalize-space(//requestId)='25'

. Regrettably, SOAPUI does not do this when evaluating the responses in load tests. Create a load test based on a test case with lots of SOAP test steps with assertions that work perfectly well run as a single test case and now you find most of the assertions are broken. Especially if the relevant DBAs are still living in the ancient world and never use varchar because they’re convinced char is dramatically more efficient.

The short story: Test SOAPUI test cases with pretty printing off at some point. Apply the XPath function normalize-space where needed to deal with leading/trailing spaces.