Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DbUnit.NET Alternatives

Tags:

.net

Are there other '.NET (2.0) Unit Testing Framework for Database Access Code' besides DbUnit.NET?

I've been trying DbUnit.NET and some things are not supported. Also, the project seems to be in alpha since 22nd May 2006...

We are refactoring our architecture to be able to do tests with mocking frameworks, but until that work is done I'd like to have a framework like DbUnit.NET (but better).

like image 786
Lieven Cardoen Avatar asked Apr 23 '09 07:04

Lieven Cardoen


3 Answers

We're using NDbUnit for one of our projects. It's a far more active project than DbUnit.NET appears to be.

like image 87
Scott Lawrence Avatar answered Nov 11 '22 23:11

Scott Lawrence


I ran into this problem a few years ago. I was annoyed at the state of DBUnit.Net. It was missing features that were important to me. Thanks to IKVM, it's not very difficult to use the normal Java version of DBUnit from dotnet. As a matter of fact, I'm running C# integration tests right now that are using the original DBUnit. Here's how I converted the java version of DBUnit into a .Net assembly:

  • Download IKVM
  • Place the following jars into a common directory: commons-collections-3.2.jar commons-logging-1.1.jar junit-4.1.jar commons-lang-2.2.jar dbunit-2.2.jar sqljdbc.jar

Now, from the command line with a working directory of the common jar directory:

ikvmc -target:libary -keyfile:yoursignature.snk -debug -version:2.2.0.0 -out:dbunit.dll *.jar

You can get necessary libraries from the following locations:

  • commons-* Apache Commons
  • dbunit.jar DbUnit homepage
  • sqljdbc.jar MSDN
  • junit.jar Junit homepage

If you are not using SQL Server as your database, then replace sqljdbc.jar with the appropriate JDBC driver. To use DBUnit directly from your .Net code, include dbunit.dll and the appropriate IKVM assemblies.

The jar versions I have given here are old. My notes on this subject are almost three years old. Newer versions will probably work, but I have not tried them.

like image 37
Todd Stout Avatar answered Nov 11 '22 23:11

Todd Stout


Consider tdunit:

TDUnit is a unit testing utility similar to DBUnit.Net. TDUnit helps with unit testing database access by allowing you to keep identity columns and foreign key constraints enabled on your test database by allowing dependency values within the test data XML file.

TDUnit uses an XML file similar in spirit to DBUnit's to specify test data to be loaded into a database with one major difference. TDUnit allows for the creation of test data that contains identity columns and relationships between tables. For example in TDUnit you can load a customer row into the Customer table and then reference the auto generated ID (Identity Column) for the customer in the Order table. Although written in C# 3.0 it can be used from .Net 2.0 projects as long as the .Net Framework 3.5 is installed. By specifying the test data in XML files, the data required for the tests can be kept with the tests and TDUnit inserts and removes the test data. This allows your test database to remain empty, allowing for faster changes and easier distribution to the team.

~ from Project Description on their home page.

like image 6
Lucas B Avatar answered Nov 11 '22 23:11

Lucas B