I am using spring-test-dbunit and I get a warning in my Unit tests with this message:
Code:
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration
To complement the existing answers, I just wanted to add what worked for me in a Spring Boot context, using the Spring Boot configured datasource. Add the following class in your test sources (in a package that will be picked up by autoconfig) :
@Configuration
public class DBUnitConfig {
@Autowired
private DataSource dataSource;
@Bean
public DatabaseDataSourceConnectionFactoryBean dbUnitDatabaseConnection() {
DatabaseConfigBean bean = new DatabaseConfigBean();
bean.setDatatypeFactory(new H2DataTypeFactory());
DatabaseDataSourceConnectionFactoryBean dbConnectionFactory = new com.github.springtestdbunit.bean.DatabaseDataSourceConnectionFactoryBean(dataSource);
dbConnectionFactory.setDatabaseConfig(bean);
return dbConnectionFactory;
}
}