Daily Usage Issues

Code Coverage not respecting ExcludeFromCodeCoverage

Started by greba on 16,373 views

Just installed 1.39b and tried NCrunch Metrics. It doesn't seem to be respecting the ExcludeFromCodeCoverage attribute.
NCrunch uses a different mechanism for handling and excluding code coverage, so framework-specific attributes such as this one are not supported by the metrics view. If you wish to avoid aggregating metrics from certain areas of your source code, currently the only way to do this is to use the 'Exclude from metrics aggregation' option on the metrics view toolbar or via the context menu option.

Cheers,

Remco
Understood.
Is this the appropriate place to make a feature request? Support for ExcludeFromCodeCoverage would be beneficial.
Thanks - many people are asking for this, so it looks like it will eventually be implemented :)
Bump. Any word on when this feature might be delivered?
Hi,

I can't give any firm plans on when this will be added. It may be in the 1.45 release, although I recommend not holding out for it. For the time being, try using code coverage suppression instead.


Cheers,

Remco
For anyone interested, support for the ExcludeFromCodeCoverage attribute has been introduced with the newly released version of NCrunch (v1.45).
Hello, looks like ExcludeFromCodeCoverage attribute is supported only for AttributeTargets.Class. Attributing methods does not have any effect on NCrunch.
NCrunch does support this attribute at method level, but be aware that methods containing the following will likely be unaffected by the attribute:

- Lambda expressions (contents of lambda will still be shown with code coverage)
- Yield return (iterator) methods
- ASync/Await methods

This is due to the inherent limitations of using an attribute to restrict code coverage data. This attribute doesn't get passed on by the compiler to any structures it generates to deal with the above situations. All code coverage tools that use the ExcludeFromCodeCoverage attribute encounter this problem, including MSTest (for which it was originally intended).

I recommend avoiding the use of this attribute. NCrunch's code coverage suppression comments leave less of a mark on the compiled code and are not subject to the above limitations.

Post a reply

Log in to reply.