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
6
votes
4 answers

Is there a DbUnit alternative that works with MongoDB?

I am developing a project that uses Spring Data and MongoDB to manage the persistence layer. I came across the need to populate some MongoDB collections with data that my integration and unit tests should manipulate. Currently I am using TestNG (and…
Marco Ferrari
  • 4,914
  • 5
  • 33
  • 53
6
votes
3 answers

Changing Database schemas & unit tests

     Before we start I know a fair few people consider tests that hit the database not "unit tests". Maybe "integration tests" would be a better name. Either way developer tests that hit the database.      To enable unit-testing I have a developer…
Michael Lloyd Lee mlk
  • 14,561
  • 3
  • 44
  • 81
6
votes
2 answers

POI Appending .0 while reading numeric data from excel

I am using POI HSSF to read excel data and I am using JUnit to check the data against database proc RefCursor. The Junit test fails as the numeric data from the Refcursor for example 100 are compared against the data in the excel sheet 100 but it…
user1669327
  • 135
  • 3
  • 9
6
votes
3 answers

Why should I avoid using DbUnit to test MySQL?

I have recently become involved with some TDD using PHPUnit. I have to test a database-driven app, and read about the DbUnit extension, which I was planning to research and implement over the coming weeks. However, I have come across this…
user1027562
  • 265
  • 4
  • 13
6
votes
3 answers

JUnit + DbUnit: Switch database connection between development and testing environments

I'm setting up some test scaffolding around an existing project. This includes some integration tests, using JUnit and DbUnit. I've also set up a Jenkins installation for continuous integration. My problem involves changing the DB connections…
Eric Grunzke
  • 1,487
  • 15
  • 21
6
votes
2 answers

What is a good strategy to assert updated data in Database with DBUnit?

Here are some (overly) simplified code example to describe my unit testing method. CompanyDataSet.xml CompanyDaoTest.java @Test public void testUpdateCompany() { …
Rangi Lin
  • 9,303
  • 6
  • 45
  • 71
5
votes
2 answers

How to load data into data base using dbunit in Maven

Below is my pom.xml file:
Melissa
  • 51
  • 1
  • 3
5
votes
2 answers

What kind of tools are available for populating test data into mongodb

What kind of tools are available for populating test data in mongodb. We have used dbunit in the past, but it doesn't seem to have an equivalent maven plugin.
Jason
  • 12,229
  • 20
  • 51
  • 66
5
votes
2 answers

Turning IDENTITY_INSERT ON on a table to load it with DB Unit

I try to load a table, that have an identity column, with DB Unit. I want to be able to set the id value myself (I don't want the database generate it for me). Here is a minimal definition of my table create table X ( id numeric(10,0) IDENTITY…
Octave
  • 351
  • 2
  • 11
5
votes
1 answer

DBUnit dataset export by set of primary key

I tried to export a dataset from an oracle database by a set of primery keys using: TablesDependencyHelper.getDataset(connection, fullTableName , new TreeSet(Arrays.asList( new BigDecimal[]{new…
cesarggf
  • 1,752
  • 2
  • 11
  • 10
5
votes
3 answers

Putting BigDecimal data into HSQLDB test database using DbUnit

I'm using Hibernate JPA in my backend. I am writing a unit test using JUnit and DBUnit to insert a set of data into an in-memory HSQL database. My dataset contains: Which maps to an…
JMM
  • 3,922
  • 6
  • 39
  • 46
5
votes
1 answer

How to insert line breaks dbunit dataset

How to insert line break in dbunit dataset? Like this: If I do it in this way field story in db appears divided by spaces only but I need a line break.
Vladimir
  • 12,753
  • 19
  • 62
  • 77
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
2 answers

JAXBException: "package" doesnt contain ObjectFactory.class or jaxb.index

I have been playing with JAXB / MOXy a lot lately, and it works great on all my tests and example codes. I exclusively using binding files, that's why I'm using MOXy. Please note that in all my examples, I'm NEVER using an ObjectFactory nor a…
avi.elkharrat
  • 6,100
  • 6
  • 41
  • 47
5
votes
1 answer

DBUnit and Spring Boot - Data may not be imported or existing when requesting in an integration test

If I run dbunit with the following setup and request data via HTTP in an integration test, I didn't get any data because the database is empty. DBUnit writes data to the database, but it's empty when I request the data via HTTP. This is my…
David
  • 177
  • 2
  • 11