Quantcast
Channel: SharpDevelop Community
Viewing all articles
Browse latest Browse all 1764

OpenCover: SD reports auto properties as not covered when they are

$
0
0

I think I've found a bit of an issue with the way SD reports code coverage of auto properties. I have a class which declares an auto property like this

public string MemberName { get; private set; }

I have a unit test for that class, which calls that property, but when I run it with code coverage from within SD, it reports that the property has not been covered (not highlighted in the code window, as opposed to being highlighted in red or green).

I've tried running OpenCover and ReportGenerator via the command line thus...

C:\Users\Simon\Documents\SD\OpenCover>"C:\Program Files (x86)\SharpDevelop\5.1\bin\Tools\OpenCover\OpenCover.Console.exe" -register:user -target:"C:\Program Files (x86)\SharpDevelop\5.1\bin\Tools\NUnit unit-console-x86.exe" -targetdir:"C:\Users\Simon\Documents\SD\SDE\Source\CodeQuality\CodeQuality.Tracing.UnitTests\bin\Debug" -targetargs:"\"C:\Users\Simon\Documents\SD\SDE\Source\CodeQuality\CodeQuality.Tracing.UnitTests\bin\Debug\SDE.CodeQuality.Tracing.UnitTests.dll\" /run=\"SDE.CodeQuality.Tracing.UnitTests.MemberIdentityTest\"" -filter:"+

  • * -
  • [SDE.CodeQuality.Tracing.UnitTests]* -[SDE.CodeQuality.UnitTesting]*" -output:"C:\Users\Simon\Documents\SD\OpenCover\CodeCoverage.xml"
    Executing: C:\Program Files (x86)\SharpDevelop\5.1\bin\Tools\NUnit unit-console-x86.exe
    NUnit-Console version 2.6.3.0
    Copyright (C) 2002-2012 Charlie Poole.
    Copyright (C) 2002-2004 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov.
    Copyright (C) 2000-2002 Philip Craig.
    Copyright (C) 2006 Daniel Grunwald.
    Copyright (C) 2006-2008 Matt Ward.
    All Rights Reserved.

    Runtime Environment -
       OS Version: Microsoft Windows NT 6.1.7601 Service Pack 1
      CLR Version: 4.0.30319.18444 ( Net 4.5 )

    DomainUsage: Single
    Selected test(s): SDE.CodeQuality.Tracing.UnitTests.MemberIdentityTest
    .........
    Tests run: 9, Errors: 0, Failures: 0, Inconclusive: 0, Time: 0.0543827689486657 seconds
      Not run: 0, Invalid: 0, Ignored: 0, Skipped: 0

    Committing...
    Visited Classes 2 of 4 (50)
    Visited Methods 2 of 27 (7.41)
    Visited Points 35 of 305 (11.48)
    Visited Branches 8 of 84 (9.52)

    ==== Alternative Results (includes all methods including those without corresponding source) ====
    Alternative Visited Classes 2 of 4 (50)
    Alternative Visited Methods 8 of 59 (13.56)

    C:\Users\Simon\Documents\SD\OpenCover>"C:\Users\Simon\Downloads\ReportGenerator_1.9.0.0\bin\ReportGenerator.exe" -reports:"C:\Users\Simon\Documents\SD\OpenCover
    \CodeCoverage.xml" -targetdir:C:\Users\Simon\Documents\SD\OpenCover\
    Loading report 'C:\Users\Simon\Documents\SD\OpenCover\CodeCoverage.xml'
     Preprocessing report
      Added coverage information of 32/32 auto properties to module 'SDE.CodeQuality.Tracing'
     Initiating parser for OpenCover
      Current Assembly: SDE.CodeQuality.Tracing
    Analyzing 4 classes
     Creating report 1/4 (Assembly: SDE.CodeQuality.Tracing, Class: SDE.CodeQuality.Tracing.FakeTracer)
     Creating report 3/4 (Assembly: SDE.CodeQuality.Tracing, Class: SDE.CodeQuality.Tracing.Tracer)
     Creating report 2/4 (Assembly: SDE.CodeQuality.Tracing, Class: SDE.CodeQuality.Tracing.MemberIdentity)
     Creating report 4/4 (Assembly: SDE.CodeQuality.Tracing, Class: SDE.CodeQuality.Tracing.TracerBase)
     Creating summary
    Report generation took 1 seconds

    And this creates a HTML report called SDE.CodeQuality.Tracing_MemberIdentity.htm which has my property highlighted in green.

    So I guess SD is incorrectly interpreting the CodeCoverage.xml file by saying that the MemberName property is not covered by the unit tests that I've run?

    Viewing all articles
    Browse latest Browse all 1764

    Trending Articles