Paulius
Paulius

Reputation: 5870

Is it possible to Unit Test SQL (MS SQL Server 2005)?

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.

Upvotes: 1

Views: 1884

Answers (5)

WileCau
WileCau

Reputation: 2197

For completeness, here's a link to the the tSQLt framework that @DavidAtkinson referred to . At first glance it seems promising, including providing easy ways to create fake tables based on real ones, moving constraints to the fake tables, etc.

I was previously using TST and was quite happy with it. It doesn't seem to be actively developed though.

It's been a while but I think the reason I used TST over tSQLt is because TST has it's own database whereas tSQLt is installed into the database being tested. I liked the idea of keeping the tests and development databases separate. In my case I had one database with the TST framework, one with my own unit tests, and the (empty) development database that was being tested.

Upvotes: 0

David Atkinson
David Atkinson

Reputation: 5909

Here at Red Gate we've built a unit test runner into SSMS called SQL Test that builds on the tSQLt framework. We'd be interested in feedback on this from anyone who wants to automate their SQL testing! For more info, visit www.sql-test.com

Upvotes: 1

Ladi
Ladi

Reputation: 11

Try TST: http://tst.codeplex.com/

Upvotes: 1

Peanut
Peanut

Reputation: 19407

"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

Upvotes: 2

stephendl
stephendl

Reputation: 722

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.

Upvotes: 5

Related Questions