views:

293

answers:

4

I´m looking for a unit tests framework for database development. I´m currently developing for SQL Server 2000, 2005 and 2008. Do you know of any good frameworks with similar functionality as JUnit and NUnit?
Perhaps it´s better to ask, what do you use to unit test your stored procedures and user defined functions?

+4  A: 

There is TSQLUnit... Link here: http://tsqlunit.sourceforge.net/

mannu
TSQLUnit is excellent.
Pittsburgh DBA
A: 

Isn't that question quite similar to What is the best way to test a stored procedure? ?

VonC
Perhaps, but my focus is to look for a way to automate the process. And more importantly get my developers to formally write unit tests for the database just as they do for .NET classes, functions etc.
bjorsig
+2  A: 

I tend to use a data access assembly and test that with NUnit using the idea outlined in http://weblogs.asp.net/rosherove/articles/dbunittesting.aspx it uses transactions to rollback changes. This is not a dedicated database approach but is good if you want to test at a higher level than pure database.

It may be worth having a look at http://weblogs.asp.net/rosherove/archive/2004/07/12/180189.aspx

dice
I have a feeling that there are occasions when Osherove's technique won't work - such as when you need separate sessions to see committed data. However, there is undoubtedly some good advice in the article.
Jonathan Leffler
+1  A: 

I'm currently using DBUnit in my project. It's quite a good tool to test a database to see if the results you expect are there, but also it can alter the data in a database to predefined values, for example, it will reset a database to the data you were using before the tests, leaving the tables unchanged.

http://dbunit.sourceforge.net/

Richard