Unit testing databases with DBUnit, Spring and TestNG

In this blog post, Nicolas Frankel explains how to perform unit testing on a database using DBUnit, Spring and TestNG. DbUnit is a JUnit extension for database-driven projects that, among other things, puts your database into a known state between test runs. This is an excellent tool to avoid the issues that can occur when one test case corrupts the database and causes subsequent tests to fail. DbUnit has also the ability to export and import your database data to and from XML datasets.

TestNG is a testing framework inspired from JUnit and NUnit but introducing some new functionalities like annotations that make it more powerful and easier to use. The post provides a step by step procedure on how to use these unit testing tools together with Spring with code examples. You will find also a “further reading” section to improve the basic setting described in the post.

1 Comment on Unit testing databases with DBUnit, Spring and TestNG

Comments are closed.