This requires a testrunconfig file that has been configured correctly. To do this I did the following:
- In VS2008, right click on Solution Items folder and select Add - New Item...
- Select Test Run Configuration and enter the name WithCodeCoverage.testrunconfig.
- Open/edit this file in VS.
- Select the 'Code Coverage' item on the left, then selected (checked) the assemblies I wanted to instrument
- Click Apply to save these changes.
Note that you can select which is the active test run configuration from under the Test menu in VS2008.
Now we need to update the TFS build...
- Open your TFS build file (eg TFSBuild.proj)
- In the section starting with
<PropertyGroup>
<!-- TEST ARGUMENTS...
Add the following line (after the comments and before the closing of PropertyGroup):
<RunConfigFile Condition=" '$(IsDesktopBuild)' != 'true' ">$(SolutionRoot)\DEV\Release1\Source\WithCodeCoverage.testrunconfig</RunConfigFile>
(update accordingly to suit your build server paths).
That's it. Queue a build to test - you may need to verify your server build paths to get it working (I did).
HTH
Tim