Freigeben über


Checkin Policy for Database Unit Testing

Team Edition for Database Professionals, combined with Team Test and Team Foundation Server, provides a facility for allowing you to enforce a team-wide policy requiring that a set of tests are run and pass before every check-in. This is a practice that can be added to your team’s processes to ensure high quality of your code check-ins.

At a high-level, doing so requires three core steps. The first is setting up a test list containing the tests that you wish to run as part of your check-in policy. The second part is creating the check-in policy for a Team project. The final part is checking in and seeing the policy in action. The steps needed to do this are outlined below.

The below walkthrough assumes that you have a solution containing your database project and your test project and this solution has been checked into source control under a specific Team Project.

Part 1: Setting up your test list

1. Open your existing Visual Studio solution

2. Go to the Test Manager by clicking on Test->Windows->Test Manager

3. Create a new test list by selecting Lists of Tests and clicking to add a test list

4. Name the test list CheckInPolicyTests and click OK

5. Click on All Loaded Tests and drag the tests you want to run on check-in into the CheckInPolicyTests test list

6. Now is a good time to make sure that your tests currently pass

7. Check your solution back into source control

Part 2: Creating the check-in policy

1. Open up the Team Explorer window and connect to your Team Foundation Server

2. Right click on the Team Project which you wish to add the policy to and select Team Project Settings -> Source Control

3. Go to the Check-in Policy tab and click Add

4. Select Testing Policy, click OK and navigate to the folder where you placed your test project under source control

5. Select the .vsmdi file which is in your project folder and click OK

6. Select the CheckInPolicyTests test list and click OK

7. Click OK once more in the Source Controls Settings dialog to finish creating the check in policy

Part 3: Checking in

1. Run the CheckInPolicyTests test list

2. Check-in the project

The way the policy works is that you must run the test list as the last thing you do prior to checking in your changes. If you fail to run the test list, when you attempt to check-in, the check-in will fail saying that the check-in policy has failed. If you make edits to your files after running your tests, the check-in policy will also fail. You can override the check-in policy by providing a reason that you are checking in when the check-in fails to meet the policy.

Roger Roach

Sachin Rekhi

Comments

  • Anonymous
    July 25, 2006
    The comment has been removed

  • Anonymous
    July 26, 2006
    You are correct that you will not be able to do this w/o Team Test (or, of course, Team Suite). In order to create test lists and use Test Manager, you need to have Team Test. They do not come with Team Dev.

    In addition, checkin policies can only be defined on a Team Project, so you will also need a Team Foundation Server installed and setup.

  • Anonymous
    August 01, 2006
    Justin Angel sent me an email letting me know there are new sidekicks available.

    Rob Caron on TheServerSide.NET...

  • Anonymous
    October 23, 2006
    If you have both Team Data and Test Test (or simply Team Suite), you’ll be able to take advantage of

  • Anonymous
    May 20, 2007
    Anything that relies on the (awful) VSMDI file is more difficult than its worth...