1

I created a custom attribute called "CoverageExcludeAttribute", and placed it above the classes which I want to exclude from my code coverage analysis. But the exclusions doesn't work. The coverage report shows coverage for the Test dll along with all the referenced assemblies (which includes classes containing the exclusion attribute)

<UsingTask TaskName="NCoverExplorer.MSBuildTasks.NCover" AssemblyFile="$(Libraries)\NCoverExplorer.MSBuildTasks.dll"/>
<Target Name="NcoverCoverage">
   <NCover ToolPath="C:\Program Files\TestDriven.NET 3\NCover\1.5.8"
        CommandLineExe="D:\Xunit\xunit.console.exe"
        CommandLineArgs="MyTestDll"
        WorkingDirectory="MyWorkingDirectory"
        excludeAttributes="CoverageExcludeAttribute" 
    LogFile="coverage.log"
   />
</Target>

Am I missing something?

Thanks.

Sandeep
  • 5,581
  • 10
  • 42
  • 62
  • Have you tried it via the command line? Maybe the MSBuild target does not pass it through properly. – Shaun Wilde Jul 22 '11 at 12:51
  • how to use this thru command line?? i tried many sorts of syntaxes, but it was throwing errors.. i tried : //ea, //eas, //ias .... – Sandeep Jul 25 '11 at 06:57
  • Sorry can't help there I don't use ncover; it was just a suggestion. Try ncover /? for options – Shaun Wilde Jul 25 '11 at 07:46

2 Answers2

0

If you are using .NET Framework 4.0 you can use existing attribute

ExcludeFromCodeCoverageAttribute

From namespace:

System.Diagnostic.CodeAnalysis

That seems to be working fine for me when using NCover 1.5.8 at least when using NCoverExplorer. This attribute is picked up automatically.

Sebastian K
  • 6,235
  • 1
  • 43
  • 67
0

Make sure that your attribute is defined in a global namespace or provide a full type name in excludeAttributes.

Jakub Konecki
  • 45,581
  • 7
  • 87
  • 126