tags:

views:

88

answers:

4

I have some model objects I'm 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 frontend before implementing these services. The model objects are mostly POJO and I want to store some sample test data in files and populate them with some easy method.

E.g. having model object School (with name (String) and teachers (List)) and Teacher with lastname and firstname, I want to store actual test data in some XML / text file and create some schools containing teachers from these data.

What are you using in this situation? I'm not familiar with TTD yet, but I can't imagine that there is no generic framework for doing this.

[edit] I've choosen Spring to mock up my sample data / services, but the other alternatives mentioned here would have worked as well.

+3  A: 

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'll create the XML request for you. Fill in the values and off you go. These can be saved, so perhaps that's a good way to generate test cases.

duffymo
+1  A: 

You can also use Spring to mock your remote service(s) and their responses. In this case, all you have to do is loading an applicationContext that will simulate your backend system(s) by replying exactly what you want for your test purpose.

Olivier
+1  A: 

Why not keep the test data in Java? You have no extra stages, formats or libraries to deal with. It's fast and you have the power and familiarity of Java on your side.

Tom Hawtin - tackline
+1  A: 

First, I'd agree with duffymo that XStream and SOAP UI are viable options. However, I've also used the approach described by Tom Hawtin, as described below.

A helper class constructs a set of test instances of the model classes, some valid and some invalid in specific ways, and builds the appropriate object graphs. An initial test case uses a valid object object graph. Successive tests substitute invalid objects for valid ones in the initial setup, checking that the appropriate errors are returned.

The helper class provides a single point of control for constructing objects whose contents are appropriately related for the scenarios needed in testing.

joel.neely