Questions tagged [dbunit]

DbUnit is a JUnit extension targeted at database-driven projects that, among other things, puts your database into a known state between test runs.

DbUnit is a JUnit extension targeted at database-driven projects that, among other things, puts your database into a known state between test runs.

614 questions
64
votes
14 answers

Is there a dbunit-like framework that doesn't suck for java/scala?

I was thinking of making a new, light-weight database population framework. I absolutely hate dbunit. Before I do, I want to know if someone already did it. Things i dislike about dbunit: 1) The simplest format to write and get started is…
egervari
  • 22,372
  • 32
  • 121
  • 175
26
votes
5 answers

DAO Unit testing

I have been looking at EasyMock and tutorials/examples around using it for Unit Testing DAO classes, for an "outside container" test. However, I think most of them talk about testing the Service Layer instead, mocking the DAO class. I am a bit…
Dchucks
  • 1,189
  • 5
  • 22
  • 48
23
votes
5 answers

Is there any way for DBUnit to automatically create tables?

I just realized that DBUnit doesn't create tables by itself (see How do I test with DBUnit with plain JDBC and HSQLDB without facing a NoSuchTableException?). Is there any way for DBUnit to automatically create tables from a dataset or dtd? EDIT: …
neu242
  • 15,796
  • 20
  • 79
  • 114
20
votes
6 answers

DbUnit - Warning: AbstractTableMetaData

I am using DbUnit in the latest version 2.4.8 and I get many warnings in my Unit tests with this message: WARN : org.dbunit.dataset.AbstractTableMetaData - Potential problem found: The configured data type factory 'class…
Tim
  • 13,228
  • 36
  • 108
  • 159
18
votes
1 answer

DbUnit and binary data

I use DbUnit for unit-testing of my DAO objects. It works great so far. I have a problem, I have field ob type byte[] which is stored as BLOB in the database. The column is not-null. How can I specify the value for this column in the XML dataset…
Ula Krukar
  • 12,549
  • 20
  • 51
  • 65
16
votes
4 answers

dbunit in phpunit is not truncating the tables

I am currently using PHPUnit and DBUnit for my project. I have a problem in DBUnit because DBUnit PHPUnit_Extensions_Database_TestCase­Src class does not seem to be truncating the existing data on the test db. So this makes my insertion tests fail…
LostMohican
  • 3,082
  • 7
  • 29
  • 38
16
votes
9 answers

DbUnit: NoSuchColumnException and case sensitivity

Before posting this I googled a bit, I looked for in dbunit-user archives and a bit also in DbUnit bug list, but I'm not found what looking for. Unfortunately, answers here did not help me either. I'm using DbUnit 2.4.8 with MySQL 5.1.x to populate…
Giorgio Vespucci
  • 1,586
  • 3
  • 18
  • 30
16
votes
9 answers

JPA - How to truncate tables between unit tests

I want to cleanup the database after every test case without rolling back the transaction. I have tried DBUnit's DatabaseOperation.DELETE_ALL, but it does not work if a deletion violates a foreign key constraint. I know that I can disable foreign…
Theo
  • 3,074
  • 7
  • 39
  • 54
16
votes
3 answers

How do I test with DBUnit with plain JDBC and HSQLDB without facing a NoSuchTableException?

I am trying to use DBUnit with plain JDBC and HSQLDB, and can't quite get it to work -- even though I've used DBUnit with Hibernate earlier with great success. Here's the code: import java.sql.PreparedStatement; import…
neu242
  • 15,796
  • 20
  • 79
  • 114
15
votes
2 answers

dbunit best practices for performance

What are some best practices/principles to follow, beyond those recommended on the actual dbunit site, that can greatly speed up tests as well as keep them maintainable? I long for a library like factory girl for java, but it doesn't look like it's…
egervari
  • 22,372
  • 32
  • 121
  • 175
15
votes
4 answers

Date relative to current in the DBUnit dataset

I'm wondering if there is any way to specify for example tomorrow as date in the DBUnit XML dataset. Sometimes code logic is different for dates in future and dates in the past and I want to test both cases. For sure I can specify something like the…
VestniK
  • 1,910
  • 2
  • 17
  • 29
15
votes
4 answers

Spring Test DBunit Warning

I am using spring-test-dbunit and I get a warning in my Unit tests with this message: Code: @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = { "/context.xml"}) @TestExecutionListeners({…
Ye Kyaw Kyaw Htoo
  • 702
  • 2
  • 9
  • 22
15
votes
8 answers

How to access common resource files from multiple projects

In one of my projects I have resources stored in /src/test/resources (typical maven directory structure). Those resources are being used by an utility class stored in the project. The utility class itself is being used from other projects (other…
FazoM
  • 4,777
  • 6
  • 43
  • 61
13
votes
2 answers

Best way to create / drop a database before / after integration testing on a Maven/Junit/DBUnit project?

I've seen some people use the maven-sql-plugin to do this. But it seems like a task that is better suited for DBUnit....perhaps at the beginning of an entire test suite. What's the best practice here?
Dave
  • 21,524
  • 28
  • 141
  • 221
13
votes
2 answers

import/export xml for dbunit

How can we easily import/export database data which dbunit could take in the following format? I'd like to find a way to export the existing data from database for my…
blue123
  • 2,937
  • 7
  • 27
  • 29
1
2 3
40 41