Eric Lefevre-Ardant on Java & Agile

March 22, 2007

Limitations when using DbUnit in multi-schema environment

Filed under: java, test — Eric Lefevre-Ardant @ 6:35 pm

DbUnit has a useful feature when using multiple schemas. After setting a property called http://www.dbunit.org/features/qualifiedTableNames, DbUnit will always refer to a fully qualified table name, using the schema in prefix, as expected.

However, it has the side-effect that the schema is then expected to be stored in the data sets. For example, if using Excel files, you’ll need to rename each sheet. Which is feasible, I guess.

The problem comes when you have multiple developers. You usually do not want them to share a database instance, as running the unit test will frequently reset the data. How do you work around that one?

Another thing is that writing the name of a schema is often overkill, even for test. What I’d really want is default to the user name, as SQL clients often do. Why cannot DbUnit do that?

Update (23/03): DbUnit is supposed to take the default schema name from the JDBC connection. However, that apparently does not work when the schema name is specified in the Hibernate configuration. Since I want to obtain the JDBC connection from the Hibernate connection, I am kind of stuck.

Powered by WordPress