O'Reilly logo

Swing Extreme Testing by Tim Lavers, Lindsay Peters

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 16. Tests Involving Databases

One of the difficulties with unit testing complex systems is dealing with databases. If our software interacts with one or more databases—either to make queries on an external system or as a persistence mechanism— we will need to test our software using databases in some known state.

One way of handling this problem is to use a tool such as DbUnit (see www.dbunit.org) to populate databases with pre-determined data sets. Such databases can then be used in unit tests. Apart from being restricted to relational databases, a problem with this approach is that being "database-centric", it does not easily mesh with the "class-centric" approach for unit testing. For example, if the database schema changes ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required