Risposta suggerita VS 11 Beta Code Coverage and .testsettings files

  • Thursday, March 22, 2012 11:07 PM
     
     
    I'm in a weird catch-22 where if I select my .testsettings files created for our VS 2010 SLN I'm not getting code coverage.  But if I deselect the .testssettings file I get code coverage but unfortunately a number of tests now file because the deployment stop of the .testsettings file isn't getting run.  Is there a way I can get both?  BTW I tried checking both Code Coverage and Code Coverage (Visual Studio 2010) diagnostics but I still get not code coverage results ie. everything is 100% not covered.

All Replies

  • Tuesday, March 27, 2012 9:12 AM
     
     

    Hi Keith,

    Can you please disable both the Code Coverage and Code Coverage (Visual Studio 2010) data collectors from the Test Settings, then select it as the active Test Settings and then use the "Analyze Code Coverage" option under the "Run" drop down in the "Unit Test Explorer".

    In the case of when you have Code Coverage enable in test settings, the coverage data will get generated even if you hit "Run All", but the coverage file is not loaded in VS by default. You will have to open the latest Test Results folder and inside the "In" folder, you should have the .coverage file available.

    -Ankit

  • Wednesday, March 28, 2012 12:43 AM
     
     
    That worked but I had to also uncheck the Intellitrace option in Data & Diagnostics.  Hopefully I still get Intellitrace when debugging my unit tests?
  • Wednesday, March 28, 2012 3:02 AM
     
     

    Intellitrace should be available to you while Debugging unit tests.

    As for Code Coverage not working with Intellitrace, it is supposed to work, are you able to see any messages in Test Ouput?

    Can you please try to execute the tests from Dev 11 command line using: vstest.console <yourtest.dll> /settings:<yourtestsettingsfile> /enablecodecoverage /logger:trx

    Let us see if we can get any warnings in it.

  • Wednesday, March 28, 2012 4:15 PM
     
     

    OK. Enabled Intellitrace then ran the above command and got this output:

    Starting test execution, please wait...
    Warning: Using Isolation mode to run the tests as diagnostic data adapters were
    enabled in the runsettings. Use /inIsolation switch to suppress this warning.
    Passed   Create_NonExistingFile_FileCreated
    <snip - all passed>

    Total tests: 36. Passed: 36. Failed: 0. Skipped: 0.
    Test Run Successful.
    Test execution time: 23.7743 Seconds
    Results File: C:\Tfs\ESAP\Branches\Feature\DataExchange\hillr_HILLR2 2012-03-28
    10_03_20.trx

    However when I load this TRX file into VS 11 Beta and then look at the coverage results, it shows 100% not covered.  However when I look at the size of the data.coverage file it is 457 KB.  Want me to submit a connect issue and attatch the TRX/Coverage files?  Or I can email them to you.


  • Wednesday, March 28, 2012 5:17 PM
     
     Proposed Answer

    Hi Keith,

    I am also able to repro this bug locally on my setup. Thanks for finding it.

    I will file it and we will try to get this fixed by RC/RTM.

    Regards,

    Ankit

  • Wednesday, March 28, 2012 7:43 PM
     
     
    Thanks!