web analytics
Press "Enter" to skip to content

Code Coverage – Combining IIS and Test Process numbers

Lars Fiedler

Here at Composable, we’re big fans of Continuous Integration, and have suites of tests that run on every change we check in. One of the metrics that we’re always looking to improve is our Code Coverage.



To enable Code Coverage during a test run, you need to use the switch “/Enablecodecoverage” on the vstest.console.exe process.  We also configure our run settings file to exclude things like auto-generated code, and only include our assemblies.

Note that we have CollectAspDotNet option set to false.  If true, this option will restart IIS for you, and add a code coverage collector on the w3wp.exe process.  However, when the collector combines the results with what’s been collected in vstest.console.exe, it will not combine the two, and vstest.console.exe will TRUMP the results for any assemblies loaded in the same processes.

To circumvent this, we started the IIS code coverage ourselves using the below command

Note that the config file for CodeCoverage is similiar to the run settings, but is not the exact schema.

To Stop the code coverage, you can do:

When publishing your test results, also include the IISCodeCoverage folder, and VS Online will include these results in the overall numbers and final coverage file.

Lars Fiedler