File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Testing and the fly likes Testing dynamic content Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Testing
Bookmark "Testing dynamic content" Watch "Testing dynamic content" New topic

Testing dynamic content

Mike Cornell

Joined: Feb 19, 2004
Posts: 1
Quite new to using jUnit, and of course, I am trying to use it for something other than it's base intended purpose.
I am part of a group who itegrate customers onto a platform. In this case, we take data in from many customers in many different formats and parse it. The parsed data is stored in a DB which was designed via IBM's VAP. The data is therefore organized and accessed through objects. In my case, each data file that is run is a batch, and contains many records, which in turn contain information that is accessed by other objects.
What I am looking to do, is to build a framework around writing tests on the data stored inside these records.
I am struggling with the organization of these tests and resources.
Here is what I know I need:
- Something to open the DB connection and close it once for the enitre suite of tests.
- Something to create a batch object for the batch I am wanting to test
- Something to cycle through each record within a batch and execute a suite of tests on each record.
The problems I am trying to solve are thus:
- Because the data from our customers is in a format intended for printing, I need to verify that information is where they say it is. By writing a test to see if data has been parsed, I can quickly determine which records in the batch I need to troubleshoot.
- If our customer adds new data, I can quickly determine if the new data caused any of the original logic to break.
- By creating a framework that gets a record, I can write tests on the record, or on anything that the record creates, be it a web page, PDF, report, etc.
I know this really isn't a unit test in the classic sence, as the data I'm getting is dynamic. The problem is, I don't need to test if the object will get me the data I'm looking for. It will....if it exists. I need to determine if the data exists.
Does anyone have any thoughts on how I might organize the things I need to do within the jUnit framework (or extensions)
So far I have been successful at opening a DB connection, but its not persisting the way I need it to...which may be due to the way I'm trying to organize the objects.
Writing a simple test case with bounds has been easy so far...this I'm stuggling with as I'm not quite sure which objects to extend and when to use them.
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 33106

dbUnit provides some of the functionality you are looking for.
The parameterized test case pattern will let you run your tests for each record of data. This pattern is described in the archives of the yahoo group for junit:

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
I agree. Here's the link:
subject: Testing dynamic content
jQuery in Action, 3rd edition