views:

47

answers:

1

Hi All,

I have a database process written in PL/SQL that i would like to test using DBUNIT. The pl/sql program processes data from one table and generates new data into a new table. In some cases it also updates fields on the original table.

I am a bit confused in how i can use dbunit to test this. Reading up on it, it looks like i have to specify the data in an xml file but i cant figure out how to structure the xml files. Thinking about it i think i would need the following data files

  1. xml file containing data for tableA
  2. xml file containing data for tableB
  3. xml file containing data for updated tableA

The workflow is something like this

  • Load tableA
  • the pl/sql process will process the data and generate the results in tableB and update some fields in tableA
  • Load xml file for tableB and compare the results.

I am slightly confused as to how dbunit can help with this. For example

  • is the xml data loaded into memory and then compared to what is in TableB?
  • how would i compare the updates to tableA?

Please also do let me know if you can suggest a better alternative or approach to do this.

Thanks

+3  A: 

The dataset(s) in the XML file(s) can serve (at least) two purposes:

  • to initialize the table(s) used in the tests. I.e. before executing the tests, in the setup method, DbUnit is called to load the contents of the XML file(s) and insert them into the desired table(s). Then the tests have the data to work on
  • to verify the contents of table(s) after the tests.

This introduction seems to explain the how-tos clearly.

Péter Török
hi yes i was reading that article. Its very usefull. Thanks
ziggy
@ziggy if you find this answer useful, you should vote it up. And you also might want to accept some answers to some of your previous questions to improve your "accept rate" (displayed under your name in the question above); people are more inclined to help you out when they know you'll recognize their help.
matt b
Thanks i had no idea that i had to vote for the answers.
ziggy