问题
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?
回答1:
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:
- Install VS Update 1.
- Connect Microsoft Test Manager(MTM) to a Team Project (Team Foundation Server) and setup test plan etc. You can utilize the free account in Team Foundation Service to create team project.
- Create a test settings with code coverage data collector enabled.
- Run a manual test or an exploratory test with this test settings.
- You will get the code coverage file at the end of the test run.
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
回答2:
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.
来源:https://stackoverflow.com/questions/13810224/visual-studio-2012-code-coverage