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
1
vote
1 answer

DBUnit with Postgresql and case sensitivity of column names - how does it work?

I'm trying to write integration tests for our Spring Boot app. We want to use spring-test-dbunit and dbunit to setup and teardown test data on a Postgresql 9.4.2 database with an empty schema. After struggling with case insensitive table names,…
Serg Derbst
  • 444
  • 6
  • 18
1
vote
1 answer

Does DBUnit change the actual state of the database?

For example, after I setup a datasource to the actual database and use @DatabaseSetup to set it to a state, which of the following happens? 1) DBUnit connect to the actual database, delete everything, insert records specified in @DatabaseSetup, test…
1
vote
1 answer

How init DB with database-unit (Table not found in statement)?

I have a simple spring project and try to use spring-dbunit to do some services tests. I use jdbcTemplate for DB access. Beans configuration:
tostao
  • 2,803
  • 4
  • 38
  • 61
1
vote
3 answers

DBUnit issue with hibernate statelessSession

I'm trying to test my code using Spring and DBunit (http://springtestdbunit.github.io/) Once inside the unit test: sessionFactory.getCurrentSession().createCriteria(MyEntity.class).list() will return the list of entities inserted by DBUnit, so it…
Chaps
  • 119
  • 1
  • 11
1
vote
1 answer

Maven Surefire + TestNG + DBUnit: DID NOT specify which test method fail

I use DBUnit, Spring Test, TestNG and maven(come with Surefire) to run the test. But when some assertions of DBUnit failed. They do not specify which test method of mine is failed but the test method of…
1
vote
2 answers

Is it possible to create entirely new schema on every case?

Is there a way to create entirely new schema on every case? Using @DatabaseTearDown annotation is not the case here because i need to reset id generators as some of my test expectation rely on them (maybe it's a bad practice) Update on rearrange…
stanislav.chetvertkov
  • 1,620
  • 3
  • 13
  • 24
1
vote
0 answers

DBUnit dataset not accessible in test methods

I have a test like the following @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = { "classpath:META-INF/spring/testDataSpringContext.xml" }) @Transactional @TransactionConfiguration(transactionManager = "transactionManager",…
qopuir
  • 369
  • 1
  • 5
  • 20
1
vote
1 answer

Spring Data Rest Unit Tests Selectively Pass

I am investigating the use of Spring Data Rest (2.0.1.RELEASE and Spring 4.0.2.RELEASE), and have written a simple service. I have also written a simple test class (see below) using DbUnit. Unfortunately when I run the tests only the findAll method…
Steve Bosman
  • 2,599
  • 1
  • 25
  • 41
0
votes
0 answers

@Testcontainers + @DataJpaTest + Transactional

I configured our integration tests to use the database from testcontainer. We are testing the DAO layer so there are cases when another Entity is required to be passed for a DAO method. I recieve the LazyInitialzeException in case the passed input…
0
votes
1 answer

How to represent a bytes array with DB Rider in YAML configuration

I have a series of test cases using Spring Jdbc, Database Rider, and H2 — with Java 17.x. Everything works fine, but I can't find a way to represent a byte array in the YAML configuration file :/ This is what I have: @Getter @Builder public final…
x80486
  • 6,627
  • 5
  • 52
  • 111
0
votes
0 answers

@ExpectedDatabase does not recognize deleted entity with MockMvc

I am having trouble using the @ExpectedDatabase annotation from springtestdbunit: @SpringBootTest @Transactional @AutoConfigureTestDatabase(connection = EmbeddedDatabaseConnection.H2) @TestExecutionListeners({ …
0
votes
0 answers

SpringBootTest in error with h2 v2.1.214 when multiple schema

I have some tests in error after upgrading from Spring boot 2.5.6 to 2.7.3. With this upgrade, h2 version has been upgraded from 1.4.200 to 2.1.214. In the pom, the version of spring-test-dbunit used is 1.3.0. The version of dbunit is 2.7.3. For…
phildeg31
  • 169
  • 1
  • 14
0
votes
1 answer

Problems with integration tests after upgrading H2 database from 1.4.200 to 2.1.210

Recently I have upgraded H2 database in our SpringBoot project from version 1.4.200 to 2.1.210. It is used for testing purposes only. For integration testing I am using dbunit 2.4.9 hibernate 5.3.10. Hibernate persistance.xml looks like…
Mr.Rajeh
  • 73
  • 1
  • 5
0
votes
1 answer

Configure SQL Server in memory (embedded) database for testing purpose in Spring

How do I configure my Spring Boot application so that when I run unit tests it will use embedded SQL Server so that stored procedures can be executed?
0
votes
0 answers

DBUnit Referential integrity constraint violation one to one relationship

I'm writing tests for my repositories and I want to prefill my test H2 database with some data.
user1007522
  • 7,858
  • 17
  • 69
  • 113