I’m struggling to come up with a good approach to write automated acceptance tests for services based on xml over http using Fitnesse. These services have complex requests and responses with xml-elements from schemas that are not shared between services. I don’t want to create tremendous amounts of Fixture-code to build up requests, marshaling/unmarshaling and do http-invoking for each service.
I’ve looked into the RestFixture(https://github.com/smartrics/RestFixture) which seems to as a great approach to limit the plumbing effort for testing these kind of services. The only problem is generating the request in a good way. For “real” rest services this would not be a problem, but my services requires a lot of xml in the request-body.
I would like to somehow allow the tester to build up their request using a Scenario table, but since all the services uses different schemas it can’t see how I can do this without creating a really complex backing-fixture responsible for creating all the different request or several Fixtures each responsible for generating request for one service. In either case I would be back to writing expensive plumbing. Does anyone here have some thoughts on this?
I've created a fixture to tackle this problem without any additional coding: XmlHttpTest. Creating the request is not dealt with using (custom) Java code mimicking the XML structure. Instead it is dealt with as generating a text value where placeholders need to be replaced. Checks are performed using XPath expressions.
Sample usage (extracted from one of the project's GitHub wiki pages) for a single call:
(Result)
Or (using scenario to make multiple calls)
(Result)
For more complex requests the fixture also allows the usage of a Freemarker template (for things like optional elements and iteration).