How to preset model objects with test data from a file?
I have some model objects that I am using in my Java client application. Later, these model objects will be populated / retrieved from remote services (e.g. SOAP). Now I want to do manual / automatic testing of the interface before executing these services. Model objects are basically POJOs and I want to store some test data in files and populate it in a simple way.
eg. with a School object model (named (String) and teachers (List)) and Teacher with lastname and firstname, I want to store the actual test data in some kind of XML / text file and create some schools containing teachers from that data.
What are you using in this situation? I'm not familiar with TTD yet, but I can't imagine there isn't a common framework for this.
[edit] I chose Spring to model my data / services, but the other alternatives mentioned here would work as well.
source to share
Sounds like a good use of XML serialization. You can use any XML serialization tool you like: XStream, etc.
Another nice tool is SOAP UI. If you point it to the WSDL for your service, it will create an XML request for you. Fill in the values ββand release. They can be saved, so maybe this is a good way to generate test cases.
source to share
First, I agree with duffymo that XStream and SOAP UI are viable. However, I also used the approach described by Tom Hawtin as described below.
The helper class creates a set of test instances of model classes, some of which are valid and some are invalid for specific reasons, and builds appropriate object graphs. The original test case uses a valid object graph. Sequential tests replace invalid objects with valid ones in the initial setup, verifying that appropriate errors are returned.
The helper class provides a single point of control for building objects whose content is appropriately linked to the scripts required for testing.
source to share