none
Calculate Code Coverage of Metro Apps RRS feed

  • Question

  • In Visual Studio 2011 Ultimate (Beta) I can view code coverage for unit tests for a non-metro application.  However, I am unable to do so for a Metro application.

    If I  right click on a test in the Unit Test explorer and select the code coverage button, nothing happens.

    If I create a testsettings file and enable code coverage, my tests will not run.  I get this in the Output window:

    ====

    Ignoring the data collection settings, including code coverage settings if any, in this test run as data collectors are not supported in metro test execution mode.
    An exception occurred while invoking executor 'executor://mstestadapter/v1': An error occurred while initializing the settings provider named 'MSTest'. Error: The test settings file C:\source\foo\CodeCoverage.testsettings, specified in the MSTestAdapter settings, is not available. Either access to the file is denied or the file does not exist. Ensure that the test settings file is available and try again.
    The test settings file C:\source\foo\CodeCoverage.testsettings, specified in the MSTestAdapter settings, is not available. Either access to the file is denied or the file does not exist. Ensure that the test settings file is available and try again.
    ========== Run test finished: 0 run (00:00:07.4154909) ==========

    Is this a limitation of the beta, or am I doing something wrong?

    Thanks


    Friday, March 2, 2012 2:10 AM

Answers

  • Jason,

    Code coverage is not supported for Metro style apps in Beta. That is the reason you dont see any .coverage file when you click on 'Analyze Code Coverage' in Unit Test Explorer.


    -Darshan

    Friday, March 2, 2012 6:58 PM
    Moderator

All replies

  • Jason,

    Code coverage is not supported for Metro style apps in Beta. That is the reason you dont see any .coverage file when you click on 'Analyze Code Coverage' in Unit Test Explorer.


    -Darshan

    Friday, March 2, 2012 6:58 PM
    Moderator
  • Hi Darshan, is there any way we can do Code Coverage in VSTS 11 Beta ?

    I can see some options for the same under Tools->Options->Environment->Fonts and Colors. "Coverage Touched Area", "Coverage Not Touched Area" and "Coverage Partially Touched Area" are some of the mentioned options.

    Tuesday, October 9, 2012 4:15 AM
  • Code Coverage is available in Premium and Ultimate versions of Visual Studio 2012.

    Thank You
    Allen Mathias

    Tuesday, October 9, 2012 5:25 AM
  • I don't get any code coverage for Metro apps. The option is there to run it, but it does nothing.

    Friday, October 19, 2012 5:22 PM
  • Hi iamdragonwolf,

    Thanks for using VS 2012 and posting on MSDN forum.

    In VS 2012 (Ultimate & Premium), the 'Analyze Code Coverage' option works only for classic mode tests. If you try to collect code coverage for Win8 Modern Apps then a warning get logged for feature not supported yet. Warning can be seen at Tests output window (Ctrl + W, O -> Tests). You can watch same window for errors / warnings logged during test discovery / execution to troubleshoot.


    Regards,
    Vikram Agrawal,
    Developer, VSTLM, Microsoft Corporation

    Monday, October 22, 2012 4:05 AM
  • I feel there is a discrepancy during the instrumentation process.

    I observed that through command line, when vsinstr command was executed it displayed the error straightaway.

    But when I used VSTS2012 Ultimate Analyze -> Launch Performance Wizard -> Instrumentation -> Chose An executable option -> gave the exe path of the metro app -> Click Finish.

    Successfully instrumented file E:\Projects\TestCodeCoverage\TestCodeCoverage\bin\Debug\TestCodeCoverage.exe.
    PRF0005: Launch Error: Unable to execute (E:\Projects\TestCodeCoverage\TestCodeCoverage\bin\Debug\TestCodeCoverage.exe).
    PRF0009: Launch Aborted


    What I could infer is that there is an issue with the instrumentation build. If instrumentation is done correctly, then applying "vsperfcmd /start:coverage /output:myapp.coverage" command can help you create the coverage file, then you can manually launch the app and after browsiing, you can execute "vsperfcmd /shutdown" to stop the profiling. This worked out for me in a WPF app, but in Metro app as the instrumentation build was not correct, it showed me the error.

    I want to bring out the discrepancy in VSTS IDE, which I assume is giving the incorrect status about file getting instrumented succesfully. Please correct me if I am wrong.

    Thanks and Regards

    Nabarun

    Wednesday, October 31, 2012 3:45 AM
  • Has there been any updates in this front? Can we get an approach for doing code coverage for a sandbox type natured app?
    Friday, December 21, 2012 5:49 AM
  • No updates here. We will post major updates on the ALM blog when available.


    Allen Mathias
    Senior Dev Lead @ Microsoft

    Sunday, December 23, 2012 5:55 AM