ziggy
ziggy

Reputation: 15876

Question about DBUNIT and Junit

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

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

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

Thanks

Upvotes: 0

Views: 1038

Answers (1)

Péter Török
Péter Török

Reputation: 116306

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.

Upvotes: 3

Related Questions