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

How to load DBUnit test data once per case with Spring Test

Spring Test helpfully rolls back any changes made to the database within a test method. This means that it is not necessary to take the time to delete/reload the test data before each test method. But if you use the @BeforeClass Junit annotation,…
Dave
  • 21,524
  • 28
  • 141
  • 221
11
votes
3 answers

Set foreign key constraints off in PHPUnit/DBUnit

I am developing Unit tests for testing model functions. I am using PHP PDO with DBUnit 1.1.2 and PHPUnit 3.6.10 and my dataset is a yml file. I need to turn off foreign key checks while the fixtures are being loaded in the database. After that I…
Abhishek
  • 1,459
  • 3
  • 19
  • 35
11
votes
1 answer

PHPUnit and DBUnit - getting started

Does anyone have a link to a good, working tutorial or book on how to get started with adding the DBUnit layer to my PHPUNit tests? I've tried following the code in protected function getDatabaseTester() { $pdo = new…
Alex C
  • 16,624
  • 18
  • 66
  • 98
11
votes
2 answers

How can I speed up my PHPUnit + DBUnit test suite execution?

I'm running in to some real speed issues with PHPUnit/DBUnit. Anything that extends PHPUnit_Extensions_Database_TestCase takes forever to run. With 189 tests, the suite takes around 8-9 minutes. I was kind of hoping it would take 30 seconds at most…
Will Morgan
  • 4,470
  • 5
  • 29
  • 42
10
votes
1 answer

PHPUnit Database Extension - How to have an empty dataset?

I want to create a test table that is empty. Using the Example from digitalsandwich, I want something like: require_once 'PHPUnit/Extensions/Database/TestCase.php'; class BankAccountDBTest extends PHPUnit_Extensions_Database_TestCase { …
Lance Rushing
  • 7,540
  • 4
  • 29
  • 34
10
votes
6 answers

Oracle + dbunit gets AmbiguousTableNameException

I am using dbunit to create database backups, which can be imported and exported. My application can use several database engines: MySQL, PostgreSQL, SQLServer, H2 and Oracle. All of the above work fine with the following code: //…
9
votes
8 answers

org.dbunit.dataset.NoSuchTableException: Did not find table 'xxx' in schema 'null'

I know there have been discussions wrt to dbunit here. I have read most of them but I cant seem to find a solution to my problem. I have set up hibernate and spring. I am doing TDD so I had to wire up a proper DAO testing framework before writing…
user626607
9
votes
4 answers

DBUnit PostgresqlDataTypeFactory does not recognizes enum list

I'm using DBUnit for an integration test, and before executing the test code I'm running into this error: badges.track_types data type (2003, '_text') not recognized and will be ignored. See FAQ for more…
alfizqu
  • 158
  • 1
  • 16
9
votes
5 answers

Path to XML DTD for DBUnit in multi-module Java/Maven project?

I have a multi-module maven project. Within the persist module I have a number of XML files data files that reference a DTD: .....omitted for…
Dave
  • 21,524
  • 28
  • 141
  • 221
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
8
votes
2 answers

xUnit IClassFixture constructor being called multiple times

I am using xUnit for integration testing. and for that, I use a localdb instance for it. With that being said, I would like to initiate DB instance once with some pre-defined data and of course I would that stay true for all test cases. I could…
Yili Li
  • 131
  • 1
  • 1
  • 4
8
votes
2 answers

How to revert the database back to the initial state using dbUnit?

I am new to automated testing and dbUnit. So I would appreciate your advice. I am going to create a test suite, that will run the following way: create an in-memory H2 database run DDL scripts to create tables run dbUnit to insert initial data…
Igor Mukhin
  • 15,014
  • 18
  • 52
  • 61
8
votes
1 answer

FlatXmlDataSet empty table (DBUnit)

Is it possible to validate that the database has no rows for a specific table with a flat xml structure? Something like:
GregD
  • 1,884
  • 2
  • 28
  • 55
8
votes
3 answers

DBunit generates java.lang.ClassCastException: java.lang.String cannot be cast to oracle.sql.CLOB when trying to load a CLOB field

I am using the latest version of DBUnit (2.4.7), on Oracle 11GR2. I'm using Java 6 (1.6.0_15) and the latest version of Oracle's client jar (jdbc6.jar) I've been unable to successfully load any data referenced by a CLOB Oracle field from an XML file…
Paul
  • 161
  • 2
  • 4
8
votes
1 answer

DBUnit automatic dataset generation

I have seen a couple of question regarding creating datasets in DbUnit here on StackOverflow, but all of them were regarding export data from existing tables. My question is, can DBUnit create some dummy dataset basing on my database schema? I don't…
pajton
  • 15,828
  • 8
  • 54
  • 65
1
2
3
40 41