Bug Report T334341
Visible to All Users

Code Coverage doesn't take into account the [ExcludeFromCodeCoverage] attribute

created 9 years ago

The test runner, when running with coverage, should respect code marked with [ExcludeFromCodeCoverage] such that, regardless of the actual test coverage (if any), code marked with that attribute should appear fully covered.

Currently I have a class under test where the whole class is marked with [ExcludeFromCodeCoverage]. i do have a couple of unit tests that run against the class but in general when looking at coverage reports I don't want that to appear as though it's not properly covered.

When running these tests through the CodeRush for Roslyn test runner with coverage, that class currently appears as 44.44% covered, so my overall coverage (in this very small project) appears to be 67.53% covered rather than 100% covered.

Even better might be some sort of visual differentiation to show that the uncovered bits are explicitly excluded (but the overall coverage percentage shouldn't be penalized for excluded code).

Screen shot attached.

Comments (1)
AE AE
Alex Eg (DevExpress) 9 years ago

    Hi Travis,
    I totally agree that Code Coverage should provide the capability to exclude areas of code from analysis. We will introduce this feature in one of future releases.

    Answers approved by DevExpress Support

    created 9 years ago

    We have fixed the issue described in this ticket and will include the fix in our next maintenance update. To apply this solution before the official update, request a hotfix by clicking the corresponding link for product versions you require.

    Note: Hotfixes may be unavailable for beta versions and updates that are about to be released.

      Show previous comments (3)
      AE AE
      Alex Eg (DevExpress) 8 years ago

        You are welcome, Scott! I'm happy to hear that the feature works as expected.

        E E
        Eric Comte Marois 5 years ago

          Looks like the attribute still isn't taken into account when it is applied at the assembly level.

          I have an utility project within my solution for which I don't want to write any tests, and hence I don't want it to show up in coverage. So I'm using ExcludeFromCodeCoverageAttribute on the whole assembly rather than on each type. Looks like the test runner doesn't get to it, despite the attribute being marked as applicable to attributes.

          DevExpress Support Team 5 years ago

            Hi David,

            I've created a separate ticket on your behalf (T919007: CodeCoverage should ignore assemblies with [ExcludeFromCodeCoverage] attribute). It has been placed in our processing queue and will be answered shortly.

            Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

            Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.