We have very complex web based product including solid number of web services etc. I'm trying to collect code coverage for all assemblies in our product using VS 2012 command line utility vstest.console.exe. It is pretty easy to collect code coverage for Unit Tests, however, there is no flag or switch that indicates that I can attach the process to IIS or collect info for web services (both client and server sides).
Any suggestions?
On the Test menu, select Analyze Code Coverage for All Tests. You can also run code coverage from the Test Explorer tool window. Show Code Coverage Coloring in the Code Coverage Results window. By default, code that is covered by tests is highlighted in light blue.
To calculate the code coverage percentage, simply use the following formula: Code Coverage Percentage = (Number of lines of code executed by a testing algorithm/Total number of lines of code in a system component) * 100.
Enable code coverage on your project. Right-click your project and select Properties > Code Coverage. Select Enable code coverage. Click OK.
Microsoft Visual Studio Enterprise 2022 has code coverage feature, nevertheless i prefere Fine Code Coverage. Professional doesn't have code coverage built in.
Detailed instructions for collecting code coverage from IIS applications using Microsoft Test Manager(MTM) of Visual Studio 2012 Update 1 can be found in this blog: http://blogs.msdn.com/b/visualstudioalm/archive/2012/11/28/code-coverage-in-microsoft-test-manager-in-visual-studio-update-1.aspx
Here is the summary:
Alternate solution:
Use CodeCoverage.exe to collect code coverage. Path: C:\Program Files (x86)\Microsoft Visual Studio 11.0\Team Tools\Dynamic Code Coverage Tools\CodeCoverage.exe. You don't need update 1 to be installed, but I recommend that you do so. Example:
CodeCoverage collect /IIS /session:WebSession /output:MyWebApp.coverage
From the toolbar menue at the top: TEST > Analyze Code Coverage > All Tests
The results show up in the Code Coverage Results window. TEST > Windows > Code Coverage Results
I have VS2012 Premium, not sure if this feature is in other tiers.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With