Domanda

I have a MVC web application hosted on a remote server. I have created another solution and recorded Coded UI Tests on that app. Now I want to know how can I measure the Code Coverage of the other application that my tests cover. For now, Code coverage only shows the results for the test project.

So first question, Is it possible to get code coverage of a web app running on a different server? (I would think not, because of this thread)

Secondly, I tried to get the coverage by hosting the web app on my hosting it on localhost oon my machine, and bu running it from VS itself, but I am still unable to get any code coverage except the test dll itself.

  • I've made a custom CodeCoverage.runsettings file as explained in this msdn article - Customizing Code Coverage Analysis
  • I tried copying both dll and pdb files of my web app into the same folder as the assembly .dll files.
  • I provided the search path to the dll for my locally hosted application

<SymbolSearchPaths>
<Path>C:\inetpub\wwwroot\DaisyMBPublish\bin</Path> 
</SymbolSearchPaths>

Here is my CodeCoverage.runsettings file.

Where am I going wrong with this? How can I get code coverage of my application?
**I was successfull in excluding my test dll using the <exclude>*

Threads I've been to:

È stato utile?

Soluzione 2

Quoting Crystal Zhu's answer from my msdn thread here

As far as I know, VS will not be able to instrument the binaries for apps running on IIS, we can’t collect code coverage for the app hosted on IIS as we normally do in VS2013. There are some approaches to accomplish your requirement. Reference ‘IIS’ section in this blog: Collecting Code Coverage Data when Running Web/Load Tests

And AkshayGarg provided us detailed steps to collect code coverage for a web app/website published on IIS from running coded UI test in this thread: http://social.msdn.microsoft.com/Forums/en-US/57496eb5-6c36-4eb0-9f14-5a72562fcae6/how-to-get-right-code-coverage-in-coded-ui-testing?forum=vsautotest . You can try it.

Actually we also can collect code coverage metrics for ASP.NET applications running on Internet Information Server when we run coded UI tests from a lab environment in MTM.

Reference: Walkthrough: Using Code Coverage in Microsoft Test Manager

Altri suggerimenti

You can do this by using the Test Case Management features in TFS of scheduling test runs on a given environment. The way that this would work is that you would create a test suite with your automated test cases and then queue a run on an environment consisting of your server and your testbox. You can then configure the .testsettings of your server to enable code coverage while executing your tests from a different machine.

Refer these blogs which spell out the details

  1. http://blogs.msdn.com/b/visualstudioalm/archive/2012/11/28/code-coverage-in-microsoft-test-manager-in-visual-studio-update-1.aspx

  2. http://blogs.msdn.com/b/visualstudioalm/archive/2012/12/09/code-coverage-in-microsoft-test-manager-deep-dive.aspx

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top