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
5
votes
3 answers

Spring Test DBUnit and table schema name

Is it possible to set the table schema name when using @DatabaseSetup annotation from Spring Test DBUnit? Currently I'm using it like this: @DatabaseSetup("user-data.xml") public class UserMapperTest { } user-data.xml: (I also tried to set the…
perak
  • 1,310
  • 5
  • 20
  • 31
5
votes
1 answer

Dealing with reserved characters in DBUnit

I'm using DBUnit during integration tests for mocking data for a legacy Spring/Hibernate project I've inherited. Unfortunately a long while ago someone decided that it would be nice to have a user table called user, which is a reserved keyword in…
Billybong
  • 697
  • 5
  • 18
5
votes
3 answers

How to have DBUnit @DatabaseSetup to happen before spring autowiring?

Consider the typical DBUnit Spring Test (see https://github.com/springtestdbunit/spring-test-dbunit) : @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations =…
Bruno Santos
  • 1,530
  • 1
  • 15
  • 22
5
votes
1 answer

Expecting database exceptions with JUnit, Spring and HIbernate

Im using spring 3.0.7, JUnit 4.11 and DBUnit 2.4.9. I am trying to test trowing exception when saving entity with many to one relationship not specified (set to null). Here is the entity:
makcro
  • 195
  • 1
  • 3
  • 11
5
votes
3 answers

JPA tests hang while obtaining HSQL connection from Maven Command Line

Tests work individually within Eclipse (right click, run as Junit), but when I run them from the command line with maven, it stops while trying to obtain a DataSource connection to the HSQL database. LogicalConnectionImpl [DEBUG] Obtaining JDBC…
Sean Charles
  • 267
  • 3
  • 18
5
votes
2 answers

DBUnit - integrity constraint violation: foreign key no action; SYS_FK_10556

I am currently coding test with dbunit(using hsqldb). However, I have a huge Problem at initializing the db: here`s the code: /** * Init before a test starts */ @Before public void initialise() { IDataSet dataSetRating =…
maximus
  • 11,264
  • 30
  • 93
  • 124
5
votes
3 answers

Handling schema changes when working with multiple feature branches

Is there another way, or some tool, to handle database schema changes in multiple parallel feature branches other than creating a separate database for each one in development? ie. Spin up a DB in memory based on some configuration or script and…
bvulaj
  • 5,023
  • 5
  • 31
  • 45
5
votes
1 answer

DB Unit should ignore order of rows

Is there a way telling DB-Unit to ignore the order in which rows should be compared? My problem is, that I do not know in which order the rows will be written to the database, but DB-Unit forces me to give an ordered list. What I want dbunit to do…
5
votes
3 answers

How to configure mutliple transaction managers with Spring + DBUnit + JUnit

In a nutshell My command line Java application copies data from one datasource to another without using XA. I have configured two separate datasources and would like a JUnit test that can rollback data on both datasources. I use DBUnit to load data…
Brad
  • 15,186
  • 11
  • 60
  • 74
4
votes
1 answer

Is there a way to make DBUnit "Delete All" for all tables prior to inserting required rows

(Newbie DBUnit question Alert!) It appears that DBUnit for each table 'deletes all the records from a table and then does its insert operation'. This means that you can't use the xml load file order to clear the data down as any constraining record…
Michael
  • 518
  • 5
  • 13
4
votes
2 answers

Simulate trigger with dbUnit

I'm using dbUnit to put test data in DB with dataset like My problem is that there's on-insert trigger in db that populates child records into…
Chizh
  • 1,019
  • 7
  • 16
4
votes
1 answer

DbUnit - Delete rows based on non-primary key field value

It looks like DbUnit is using JDBC metadata to determine the primary key fields and constructing delete statement using those field: delete from tbl_name where pk_field1=? and pk_field2=? and pk_field3=? Is there a way to delete rows based on one…
dsatish
  • 1,041
  • 15
  • 27
4
votes
3 answers

how to use DbUnit with TestNG

I need to integrate DbUnit with TestNG. 1) Is it possible to use DbUnit with TestNG as DbUnit is basically an extension of JUnit. 2) If yes how?
user764974
  • 73
  • 1
  • 6
4
votes
4 answers

Unitils/DBunit and database test

I want to try to make unit test with DBUnit but I have a problem with my dataset. Here is my persistence object: @Entity @Table(name = "personnes") public class Personne implements Serializable { @Id @GeneratedValue(strategy =…
Kiva
  • 9,193
  • 17
  • 62
  • 94
4
votes
4 answers

DBUnit: NoSuchColumnException Non-uppercase input column in ColumnNameToIndexes cache map. map's column names are NOT case sensitive

My java application stores your information in MySql database version 8. The user information and password are stored in this database. I am implementing an integration test to test the method that validates the user in the database using dbunit.…
araraujo
  • 613
  • 2
  • 8
  • 17