views:

435

answers:

2

We are having a lot of tables, views and stuff. There are a few people working on different stuff on the same database and sometimes, we change things that screws up others work (like change the columns in the view, or changing the parameters to the stored procedure).

Is there any way, to automate these checks? I don't even know if unit tests for MS SQL is possible, so any kind of automated testing tools would be good.

Thanks.

+4  A: 

SQLUnit is made to Unit Test stored procedures.

It is based on JUnit, so can be automated in the same way as any JUnit tests can be automated - plugged into ANT, run with continuous integration tools etc.

stephendl
what about the views? what's the common practice?
Paulius Maruška
You could use SQLUnit to test the creation of the views, and that the data in the views is as you expect it to be in certain circumstances.
stephendl
Well, the problem is that we don't re-create the views. We usually just edit them on our development server. When we need to deploy - we would simply auto-generate the create scripts for everything...
Paulius Maruška
Have a test server (or database on your existing dev server) that gets recreated each time the tests run? This can all be done automatically using SQLUnit.
stephendl
+2  A: 

"Data Dude" exists as part of Visual Studio 2008 database edition. I've not used it but understand it is excellent for SQL Server unit testing. http://blogs.msdn.com/gertd/archive/tags/DBUnitTesting/default.aspx

Also check out DotNetRocks show 312 - Andy Leonard on Unit Testing your Database http://www.dotnetrocks.com/default.aspx?showNum=312

Peanut