tags:

views:

153

answers:

4

I'm developing a Java Web Application that runs a series of financial calculations for a user. When a financial calculation is run, roughly 30 different inputs are used to calculate 15 different values over a maximum of 18 years (max 15*18 expected values). As you can tell, there is a considerable amount of information to compute and validate.

What I am looking for is advice on how to prepare test data (simulate the 30 different inputs), load it into a series of objects, and run the objects through the calculator to generate the output which can then be compared to expected values.

I have attempted to stub a database, but this ended up taking forever. Mocking everything seems like it would be just as tedious. I'd like to avoid external database dependencies if possible.

A: 

Your best bet would be to use a factory that can select values at random from a pool and assemble the input from those. You can generate as many candidates from the population as you wish that way. Persist them along with the expected results. If a database isn't to your liking, perhaps XML or plain text serialization will do.

If you do TDD, you can run a few and see what the expected results ought to be. Check a few with hand calculations to make sure that they're okay. Then use the factory to generate as large a test set as you need.

duffymo
A: 

It sounds like FitNesse (http://fitnesse.org/) might be what you are looking for. You'd setup an html table in FitNesse with your inputs and your expected output. When you run the test, FitNesse will let you know if the actual output matches your expected output.

Logan5
A: 

If you have data in Db and you just want to create a test data out of it so that your Tests run are not dependent on external db.You can have a look at DbUnit framework and can populate sample data in XML from DB. These XML's you can use for Testing purpose ,these XMLs can easily be converted into say java objects by number of commanly available parsers.

Khangharoth
Have you used DBUnit and could you provide any tutorials with good sample code?
rynmrtn
Well i used DbUnit in a fairly medium size project.Their are couple of Tutorials available on Net.Also you can have a look in book "Java Power Tools" By John Ferguson Smart ,chapter on Dbunit.Still you find any problem then i can write a sample tutorial for you.
Khangharoth
+1  A: 

I would identify values around the number limits (boundary values), a realistic value and a value of zero for every input parameter. Then I'd combine them all using the allpairs algorithm (http://www.satisfice.com/tools.shtml).

Ced