Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TFS 2010 Build Automation - Enabling Code Coverage

How do you enable code coverage for unit testing in TFS2010 automatic build?

In Visual Studio 2010 we enabled Code Coverage for our test projects (Test --> Edit Test Settings --> Local Test Settings --> enable Code Coverage and choose assemblies to run code coverage against).

Now this is working fine (we can read code coverage) when running from Visual Studio 2010 (Test --> Run --> All Test In Solution).

The problem is that no code coverage is reported in TFS 2010 when building.

Note that the test projects are used by the build controller but without any code coverage.

Is very important for us to enable code coverage together with unit testing.


I forgot to mention that the problem I'm encountering has to do with code coverage for a web application project.

At step: Test --> Edit Test Settings --> Local Test Settings --> enable Code Coverage and choose assemblies to run code coverage against

when choosing assemblies you can choose the web application. I think that the problem is related to Path (the value under the Path column from wizard) which is the one from developer machine (http://localhost...). When building and deploying with TFS the build goes on one server and the deployment on another.

The question should be now: which path should be available in testsettings. The build path or the deployment path?

Currently I'm not at work and can't test my doubts. I'll let you know as soon as I get in touch with TFS.

like image 445
andreim Avatar asked Jan 19 '11 23:01

andreim


1 Answers

You need to tell the build server which test settings file to use. You will find this in the build settings under Process >2. Basic >Automated Tests >1. Test Assembly >TestSettings file.

Once you have that specified then the Code coverage should work.

like image 185
David McEwing Avatar answered Nov 19 '22 02:11

David McEwing