Rescently I began using VS testing facilities to create test cases. Its pretty nice, but there is one thing that bothered me when I discovered it wasn't in the UI.
Here is the case:
You add a new database unit test to your project. You open the designer for the new test case and find a defaulted test condition (for inconclusive). You create a test case to test a stored proceedure for a negative case where you expect it to raise an error. You mouse over to the test conditions and look for the 'Error Raised' option but find its not there. You scratch your head wondering how you are supposed to specify that the intended result of this test is an error. You use your favorite Internet search engine to see if you can find an example of how its supposed to be done. Nothing. Now what?!
Well it turns out the answer is not that hard. You write a small bit of code to wrap your test in that returns a result when there is an error.
Here is an example:
BEGIN TRY EXEC Api_CreateUserRecordsEND TRY BEGIN CATCH SELECT ERROR_NUMBER() AS ErrorNumberEND CATCH
BEGIN TRY EXEC Api_CreateUserRecordsEND TRY
BEGIN CATCH SELECT ERROR_NUMBER() AS ErrorNumberEND CATCH
You then goto your test condition and set it to "Not Empty Resultset". Of course you could select more information that what I have shown. The core message here is: Wrap your negative test case in a 'Begin Try/End Try' and 'Begin Catch/End Catch'.