org.dbunit.DBTestCase Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of dbunit Show documentation
Show all versions of dbunit Show documentation
dbUnit is a JUnit extension (also usable from Ant and Maven) 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.
package org.dbunit;
import org.dbunit.database.IDatabaseConnection;
/**
* Base testCase for database testing.
* Subclasses may override {@link newDatabaseTester()} to plug-in a different implementation
* of IDatabaseTester.
Default implementation uses a {@link PropertiesBasedJdbcDatabaseTester}.
*
* @author Felipe Leme
*/
public abstract class DBTestCase extends DatabaseTestCase {
public DBTestCase() {
super();
}
public DBTestCase(String name) {
super(name);
}
protected IDatabaseConnection getConnection() throws Exception {
final IDatabaseTester databaseTester = getDatabaseTester();
assertNotNull( "DatabaseTester is not set", databaseTester );
return databaseTester.getConnection();
}
/**
* Creates a new IDatabaseTester.
* Default implementation returns a {@link PropertiesBasedJdbcDatabaseTester}.
*/
protected IDatabaseTester newDatabaseTester() throws Exception {
return new PropertiesBasedJdbcDatabaseTester();
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy