The following will make your builds (running on a TFS Server) execute your unit tests after the build:
- Open your build file (eg TFSBuild.proj). VS2008 has a nice xml editor for this.
- Search for the RunTest node and change it from:
- Look for a section that starts with:
<!-- TEST ARGUMENTS ...
and add nodes within this (after the comments and before the closing of the ItemGroup node) - one entry for each unit test assembly you have eg:
<TestContainer Include="$(OutDir)\My.App.UnitTests.dll" />
Thats it - check in this file and queue a build.
An error I got while getting this working indicated that the MSTest.exe could not be found - this was because TFS Client had not been installed on the build server - once these were installed it worked fine.
Something else you may want to do is ensure that a build is triggered every time someone checks in. To do this, edit your build definition (right click on your build within Team Explorer and choose "Edit Build Definition...") - click on the 'Trigger' item in the list on the left and make sure the "Build each check-in (more builds)" item is checked.