Unit-Testing Database Operations with DBUnit

This was a session that showed off the DBUnit framework. DBUnit framework is based on JUnit but facilitates the testing of operations that update the Database.

It is important to put the database into a well known state before starting the tests.

Could be tested using JUnit, but there is a lot of code. Lots of code to initialize the DB, and then a lot of code to verify the results.

DBUnit is a framework for doing this type of coding. There is representations of what the data should be when the test starts, and representation of what the data should look like after the test.

This looks really promising for those types of tests that update data. It would also have excellent application to more than just Unit tests, but also automated testing of any kind of data.

Leave a Reply

You must be logged in to post a comment.