This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Hello... 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. -Mike
Mike, 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: http://groups.yahoo.com/group/junit/