Db Unit

A Wiki for writing a database Unit TestingFramework.

http://dbunit.sourceforge.net/


"About DbUnit"

"DbUnit is a JUnit extension (also usable with Ant) targeted for database-driven projects that, among other things, puts your database into a known state between test runs. This is an excellent way to avoid the myriad of problems that can occur when one test case corrupts the database and causes subsequent tests to fail or exacerbate the damage.

"DbUnit has the ability to export and import your database data to and from XML datasets. Since version 2.0, DbUnit can works with very large dataset when use in streaming mode. DbUnit can also helps you to verify that your database data match expected set of values."


Naive question: why don't you just ROLLBACK at the end of each unit test?

Because the tough part of AgileDatabases? is not testing, it's refactoring? DBs are arranged so their innermost schema tightly couples to their performance.

Not to mention that one may be testing processes that commit their own work.

And even if you isolate tests by rolling back at the end of each one, there's still a need to set up the data at the start of each transaction.

On the other hand, there's a lot to be said for the MockObject testing pattern.


EditText of this page (last edited November 21, 2014) or FindPage with title or text search