- Unit tests with JUnit / Cobertura and DOH / JSCoverage;
- Functional and Integration tests with Selenium 2.
There's one little caveat related to the conversion and the XPath assertions:
- When the server response contains a single JSON object, the conversion introduce a namespace into the generated XML.
- And this namespace depends on the server address.
|JSON response produced by a REST service.|
|Transformation into a XML payload with an inferred namespace.|
This automatic mapping to namespace server dependent does not allow to write server-agnostic code if you follow the suggested solution!
The following figures show a XPath match expression as documented in the SoapUI training materials. Sadly, running it against an XML with a namespace, this error is reported:
XPathContains assertion failed for path [//startDate/text()] : Exception missing content for xpath [//startDate/text()] in Response.
|Simple XPath expression with the corresponding error message.|
|Corrected XPath expression as suggested, now server dependent :(|
A simple solution consists in replacing the specified namespace with the meta-character '*', which match any namespace. As all elements of the XML document are under the scope of the inferred namespace, it's important to prefix all nodes of the XPath expression with '*:', as illustrated by the following figure.
|Use of the '*' prefix to produce assertion server independent.|