locked
Code coverage results not matching lines highlighted. RRS feed

  • Question

  • I am running VS Team System 2008 development edition, version 9.0.30729.1 sp

    I used command line tools to instrument my dlls and exe. These were then dropped onto one of our servers on which i ran vsperfmon to collect the code coverage results, running some functional test to exercise the code.

    After the test run i copied the resulting coverage file back onto my development machine.

    When i opened the results in vs i can see results.

    When i checked the results for some methods however they don't appear to match what has been highlighted in the code, this does not match what i expected to see based on this link.

    For one method i get the following results:

    Not Covered (Blocks)  1   

    Not Covered (%) 5.26 %   

    Covered (Blocks) 18   

    Covered (%) 94.74 %

    The code has the following format, with the BLUE indicating that the line is highlighted in BLUE, all other lines are not highlighted:

    public void MyMethod(DataType data)
        {
         Method call -- BLUE
          Method call -- BLUE
         Method call -- BLUE
          Method call -- BLUE
    
          Method call, line1 -- BLUE
           Method call, line2 -- BLUE
    
          try
          {
           Method call -- BLUE
            Method call -- BLUE
            Method call -- BLUE
          }
          catch (Exception e) -- BLUE
          {
            Method call -- BLUE
          }
    
          Method call -- BLUE
        } -- BLUE
    


    When i look at the code however i see that there are 13 lines highlighted in blue and none in red.

    From looking at the sample inserted above if i add up all the lines not highlighted within the method, including the {}'s this gives me 6 which would all add up to 13 +6 = 18(covered) +1 (not covered).

    I have another similar method which is showing 13 lines covered with 1 not covered. In this case the try catch block try and {}'s are also not highlighted but the number of lines covered in this case does match the number highlighted in blue. There are still no lines highlighted in red to account for the 1 line not covered.

    Has anyone else had issues with highlighted lines not matching results and/or getting not covered block results with no corresponding red highlighting.

    There are no beige lines in either method.

    Friday, October 14, 2011 10:50 AM

All replies

  • I just installed VS 2010 Premium, (trial version) and opened my previously created coverage file.

    The results are slightly different, for the method described above VS 2010 the following results:

    Not Covered (Blocks)  0  

    Not Covered (%) 0 %   

    Covered (Blocks) 17  

    Covered (%) 100 %


    I also notice that for a different method whith has a try catch which not exercised in my tests, VS 2008 counts the catch and the one line statement within it as 2 blocks not executed, VS 2010 reports its as 1 block not executed.
    Thursday, October 27, 2011 2:46 PM