web analytics
Press "Enter" to skip to content

Code Coverage – Combining IIS and Test Process numbers

Lars Fiedler 0

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.

codecoverage

 

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

Lars has comprehensive expertise building large complex software systems, and has served as a Software Engineer at MIT’s Lincoln Laboratory since 2010, where he began developing Composable Analytics. Prior to joining Lincoln Laboratory, Lars worked as a Software Engineer at Microsoft Corporation from 2006 to 2010. Lars received his MS in Computer Science from Georgia Institute of Technology in 2004, and his BS in Computer Science from Georgia Tech in 2003.