Tuesday, December 24, 2013

SQL Unit Tests

This presupposes you have added a unit test project to your solution. If not, create a new project in step 2 as you create the first test.
  1. Visual Studio - SQL Server Object Explorer  - projects node db - Progammability  - Stored Procedures.
  2. Right-click one of the stored procedures, and click Create Unit Tests to display the Create Unit Tests dialog box.
  3. Verify the Unit test project you are adding it to.
  4. Name the class something meaningful like TestProcDoesSomething.cs
  5. Select a connection. do you test locally on either (localdb) or localhost, or remotely on your dev or build server?
  6. Deploy the database project before testing if you are running this locally or on a personal dev vm. If running on build or shared dev boxes you may want to have something more explicit deploying.
  7. Add a test condition in the Test Conditions window. Note that scalar results are case sensitive since the programming language executing the test is C#.
  8. Right click - Properties - Add values for test and provide valid name.
  9. Delete the default inconclusive test condition.This test condition is included to indicate that test verification has not been implemented.



http://msdn.microsoft.com/en-us/library/jj851212(v=vs.103).aspx#CreateDBUnitTests

No comments:

Post a Comment