开发者

Is TSqlUnit worth using?

If I were to write some unit tests for my stored procedures, is there any benefit to doing this开发者_如何转开发 with TSqlUnit vis-a-vis C# / Entity Framework4 / TransactionScope?

It seems to me you could create an EF4 context, import your SPROCS and tables, and do whatever setup you need to in C#, call you SPROC, confirm the results with some Asserts, and have everything rolled back when your TransactionScope hits the end of the using without having been committed. Reading that back, it seems like a lot, but I think the resulting code is a lot slimmer and more readable than the corresponding stored procedures I'd have to write to do the same thing in TSqlUnit.

Is TSqlUnit more for database developers that are just more comfortable in T-SQL than C#/Visual Studio?


There may be no real benefit for you if you're using EF4 with Transactions and doing all of the development yourself.

TSqlUnit starts to add value when you're using your T-SQL from multiple applications or you're working for a large software shop where all database development is owned by a separate group (which means they will use TSqlUnit to test their code rather than relying on you to do it for them).


Generally, when you use EF or say, NHibernate or any other ERM you don't need to test your SQL SP's directly, unless you have created SP's by hand that are wrapped in EF or any ERM.

So, yes it's worth using when you there's any need in testing hand-made SQL statements. Otherwise, just stick to your favorite unit testing framework that works with .NET.

To answer your last question: TSQLUnit is meant for DB programmers (if that's the correct word). And if you have a significant amount of hand-tuned SQL programming going on (triggers, functions, stored procedures) you should consider it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜