0
我正在使用DBUnit來測試Spring/Hibernate持久性。DBUnit:如何僅在失敗時刷新?
我創建了一個抽象測試:
public abstract class AbstractTestCase extends
AbstractTransactionalDataSourceSpringContextTests {
@Override
protected String[] getConfigLocations() {
return new String[] {
"classpath:/applicationContext.xml",
"classpath:/testDataSource.xml" };
}
@Override
protected void onSetUpInTransaction() throws Exception {
DataSource dataSource = jdbcTemplate.getDataSource();
Connection con = DataSourceUtils.getConnection(dataSource);
boolean validateSchemaExists = true;
IDatabaseConnection dbUnitCon = new DatabaseConnection(con,
"MHADB_TEST", validateSchemaExists);
DatabaseConfig dbUnitConConfig = dbUnitCon.getConfig();
dbUnitConConfig.setProperty(DatabaseConfig.PROPERTY_DATATYPE_FACTORY,
new OracleDataTypeFactory());
boolean enableColumnSensing = true;
boolean enableDTDMetadata = false;
IDataSet dataSet = new FlatXmlDataSet(new File(
"./src/test/resources/mhadb-dataset.xml"),
enableDTDMetadata,
enableColumnSensing);
try {
DatabaseOperation.CLEAN_INSERT.execute(dbUnitCon, dataSet);
} finally {
DataSourceUtils.releaseConnection(con, dataSource);
}
}
}
但每當我運行一個測試,它刷新DB每個測試方法,這是相當很長,很不是很好,我認爲之前agains的數據集。
我怎麼才能重新加載/只刷新失敗?
P.S .:代碼吸了多少?