views:

23

answers:

1

Is it possible to enforce that every check-in to TFS has an associated unit test with it? Even if the associated unit test is just a shell? I don't want to allow code to be checked in without the code first having an associated unit test class.

I am using TFS 2010

A: 

Yes, but it isn't going to be easy to implement. With TFS, check-in policies are enforced on the client-side. Jim Lamb has a good article on how to do this:

http://blogs.msdn.com/b/jimlamb/archive/2010/03/31/how-to-implement-package-and-deploy-custom-check-in-policy-for-tfs-2010.aspx

It's relatively straightforward to create the policy, but where your fun is going to start is in determining whether there's an associated test class. If you are doing something by convention (e.g. MyCustomClass.cs has a test class file of MyCustomClass_TESTS.cs), you could check that both files are present in the project file. If you're thinking of doing some level of code analysis to determine this... it will get more complicated.

Robaticus