none
How to get "Code Coverage" of application under test in Coded UI Tests RRS feed

  • Question

  • Hi, new to the forums so pardon any mistakes.

    I have this project in which I am creating Coded UI Tests on my ASP.NET MVC4 Web Application. Everything works fine but

    first que: Is it possible to get the code coverage of the web application under test by CUITs? (The problem here seems to be that the application has to be hosted on local IIS(or a remote server) to be used for the tests, there is no direct call to the application dll from my test.). If yes can you please provide the steps to do so.

    second que: I did try to do this on my own, surfing through various articles on the web. Initially all I was getting was the code coverage of the test dll. But later I included a .runsettings file to Customize the Code Coverage.

    I tried to use the runsettings to include my application dll in the code coverage but no success so far.

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


    and 

    <ModulePaths>
                  <Include>
                  <ModulePath>.*DaisyMB\.UI\.dll</ModulePath>
                  </Include>
                  <Exclude>
                    <ModulePath>.*DaisyMBCodedUITest\.dll</ModulePath>
                    <ModulePath>.*CPPUnitTestFramework.*</ModulePath>
                  </Exclude>
                </ModulePaths>

    Very recently, I added the reference to the other projects in my solution to the CUIT project, strangely IT shows all dll's except my UI project(exactly the one that I need). with 0% coverage in the output .coverage file.

    FYI, I am using VS 2013. Please help me out here.

    *I am not allowed to add images and links, until my account is verified, sorry about that.
    Friday, December 27, 2013 6:43 AM

Answers

All replies

  • Hi,

    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

    Best regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, December 27, 2013 9:16 AM
    Moderator
  • Thanks for the reply Amanda, I'll be quick,

    • I've already been to the link to Akshay's answer and it wasn't very helpful.
    • The reference blog for "Collecting Code Coverage Data when Running Web/Load Tests" provided a promising approach but I learned that the Visual Studio Development server has been discontinued in VS 2013. So that was again a no go.

    The last link for "collecting code coverage metrics for ASP.NET applications running on Internet Information Server when we run coded UI tests from a lab environment in MTM" worked for me.

    So thanks once again, we'll be following up on that.





    Friday, December 27, 2013 2:34 PM