Questions tagged [spring-test-dbunit]

Spring DBUnit provides integration between the Spring testing framework and the popular DBUnit project.

Spring DBUnit provides integration between the Spring testing framework and the popular DBUnit project. It allows you to setup and teardown database tables using simple annotations as well as checking expected table contents once a test completes.

91 questions
56
votes
8 answers

Configure specific in memory database for testing purpose in Spring

How do I configure my Spring Boot application so that when I run unit tests it will use in-memory database such as H2/HSQL but when I run Spring Boot application it will use production database PostgreSQL/MySQL ?
IllSc
  • 1,419
  • 3
  • 17
  • 24
27
votes
1 answer

What are TestExecutionListeners, and what do they do?

As far as I understand, TestExecutionListeners act like @BeforeClass methods in JUnit. What I don't understand is why I need to use DependencyInjectionTestExecutionListener, TransactionalTestExecutionListener and DirtiesContextTestExecutionListener…
Ali Arda Orhan
  • 764
  • 2
  • 9
  • 24
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
9
votes
1 answer

@DatabaseSetup unable to load data set

I configured my test environment via java config. At my test I need some data upfront to run it, but when i run the test with the @DatabaseSetup annotation I always get the error Unable to load dataset from "personTestData.xml" using class…
Christoph
  • 438
  • 1
  • 6
  • 14
7
votes
2 answers

org.dbunit.dataset.NoSuchColumnException

I'm getting the following error when I run my tests: org.dbunit.dataset.NoSuchColumnException: myTable.MYFIELD - (Non-uppercase input column: myfield) in ColumnNameToIndexes cache map. Note that the map's column names are NOT case sensitive. at…
Glory to Russia
  • 17,289
  • 56
  • 182
  • 325
7
votes
2 answers

Spring integration test with manual transaction management

I've read many posts and threads about integration testing with Spring but nothing is either satisfying or helpful. We're using Spring 3.2.3 with Hibernate, Spring Data and an Oracle database. For testing we also use DbUnit and Spring-test-dbunit.…
actc
  • 672
  • 1
  • 9
  • 23
6
votes
3 answers

DbUnit and JSON column type support

I'm wondering what's the best possible way to make DbUnit work with MySQL's JSON(B) type columns? We do have such columns here and there and whenever I am trying to feed the test data from XML file via @DatabaseSetup I get the NoSuchColumnException…
ADi3ek
  • 645
  • 6
  • 18
6
votes
1 answer

DBUnit Boolean value

After learning SpringBoot, I wanted go further to handle integration tests using (DBUnit and SpringTestDBUnit). Throughout the process, everything was going well until I came across setting values for boolean datatyped columns on the dataset.…
David B
  • 3,269
  • 12
  • 48
  • 80
5
votes
1 answer

DbUnit @DatabaseTearDown annotation: how to delete only certain records? (those inserted using @DatabaseSetup annotation)

I am trying to delete only those records I inserted using the @DatabaseSetup annotation. My test looks like this: @Test @DatabaseSetup("classpath:data-set.xml") @DatabaseTearDown(value={"classpath:data-set.xml"}, type=…
Robert Bowen
  • 487
  • 2
  • 13
  • 24
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
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
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
4
votes
0 answers

Why does my UUID column result in a "Bad Base64 Input Character" with DBUnit?

I have a Hibernate DAO class with a UUID column, works fine when i run it on my server against mySQL. However, i am trying to write an integration test using DBUnit, and i get a strange error message: "Bad Base64 input character at 4:…
Mathias
  • 3,879
  • 5
  • 36
  • 48
4
votes
2 answers

Spring Test DBUnit: Unable to load dataset from file

I'm trying to use Spring Test DBUnit for running an integration test that checks if a DAO's services are running correctly. For two similar entities, I was able to create tests that run OK, but for this particular entity, the test can't run…
jmm
  • 1,044
  • 2
  • 12
  • 38
4
votes
3 answers

DBUnit & Postgres UUID Primary Key

I am trying to use DBUnit to run integration tests, however I am finding myself unable to insert the primary key columns, which obviously will not work with foreign keys referencing the primary key later on in the file. For example, I have the…
user372743
1
2 3 4 5 6 7