Theoretical scenario: We have an interface implemented using spring batch, which when triggered fetches a complicated object tree from a service. The type of service is not relevant, it is a pojo and return normal objects. It is transformed into our domain model and then using certain business logic calculations are performed. The data is sent on to the next system using another service.
So I want to test the transformation and business logic mentioned above and have quite a few test cases that already exist in dbs (behind the first services). This is a typical case for mocking. I can mock the incoming and outgoing services using one of the many mocking frameworks out there (mockito etc.). What I am wondering about is are best practices for this scenario: how can I capture the results of service calls (i.e. the result in the form of vanilla objects) and store them in serialised, marshalled form, which I can then use behind a mock?
This has to be a quite common scenario? I have found a few bits and pieces, things like XMLEncode, Xstream, simple etc. on the serialisation side of things and various test frameworks like fitnesse etc. that don't quite fit the bill. I've looked at and used mocking frameworks in the past, but I haven't found anything yet that brings both of these topics together.
Aucun commentaire:
Enregistrer un commentaire