8

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?

Gulzar Nazim
  • 51,744
  • 26
  • 128
  • 170
bjorsig
  • 1,077
  • 2
  • 7
  • 20
  • See question: http://stackoverflow.com/questions/53527/how-can-you-unit-test-a-database-in-sql-server – Ray Mar 06 '09 at 17:57

4 Answers4

4

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

mannu
  • 793
  • 3
  • 10
2

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
  • 2,820
  • 1
  • 23
  • 34
  • 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 Oct 14 '08 at 22:28
1

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
  • 9,972
  • 4
  • 26
  • 32
1

I've also come across T.S.T. the T-SQL Test Tool http://tst.codeplex.com/

JoshL
  • 141
  • 1
  • 4