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.

+1


source to share


4 answers


You can also use Spring to mock your remote services (services) and their responses. In this case, all you have to do is load an application instance that will simulate your backend system (s), answering exactly what you want for your testing purpose.



+1


source


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.

+3


source


Why not store test data in Java? You don't have additional steps, formats or libraries to work with. It's fast and you have the power and knowledge of Java on your side.

+1


source


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.

+1


source







All Articles