Thursday, 13 October 2016

XML : SoapUI: Customize assertion log text when assertion passes or fails

I have a Script Assertion that compares value A from the XML response to value B, C, and D. If Value A is equal to any of value B, C, or D then the assertion passes, else it fails.

  // get the xml response                                               def response = messageExchange.getResponseContent()                                                   // parse it                                               def xml = new XmlSlurper().parseText(response)                                                // find your node by name                                                 def node = xml.'**'.find { it.name() == 'total-premium' }                                                 // assert                                                 (assert node.toString().matches("(36.476|38.395|40.315)\\d*"))    

At the moment for a passed assertion I get this string in the log:

  Step 1 [TestStep_0001] OK: took 2296 ms    

And a failed assertion I get this string in the log:

   -> [Script Assertion] assert node.toString().matches((36.476|38.395|40.315)\\d*")           |    |          |           |    37.6033658 false           37.6033658    

As you can see it is a bit messy and I'm trying neaten up the test suite logs.

Is there a way to set customized response in the logs?

No comments:

Post a Comment