Report filters not applying

Report filters not applying

I'm having difficulties applying Filters via MSBuild to Ncover reporting. I am using Team City to integrate NCover and NDepend via MSBuild. I want to exclude certain assembles from the NCover reporting, but whatever I put in the filters, the assemblies appear in the reporting. My MSBuild file looks like this:

<!-- <?xml version="1.0" encoding="utf-8"?> <UsingTask AssemblyFile="Lib\MSBuild\NCover\NCover.MSBuildTasks.dll" TaskName="NCover" /> <UsingTask AssemblyFile="Lib\MSBuild\NCover\NCover.MSBuildTasks.dll" TaskName="NCoverReporting" /> <UsingTask AssemblyFile="Lib\MSBuild\NDepend\NDepend.Build.MSBuild.dll" TaskName="NDependTask" /> <PropertyGroup> <!-- NUnit -->
<!-- BUILD_NUMBER provided in environment from TeamCity -->
<NCoverVersionForMSI>$(BUILD_NUMBER)</NCoverVersionForMSI>
<NCoverVersionPeriod>$(BUILD_NUMBER)</NCoverVersionPeriod>

<Reports>
    <Report>
        <ReportType>SymbolModule</ReportType>
        <Format>Html</Format>
        <OutputPath>Tests\Output\Coverage\symbolmodule.html</OutputPath>
    </Report>
    <Report>
        <ReportType>FullCoverageReport</ReportType>
        <Format>Html</Format>
        <OutputPath>Tests\Output\Coverage\Full\index.html</OutputPath>
    </Report>
</Reports>

<CoverageFilters>  
  <Filter>  
    <Pattern>*Repositories*</Pattern>  
    <Type>Assembly</Type>  
    <IsRegex>True</IsRegex>  
    <IsInclude>False</IsInclude>  
  </Filter>
  <Filter>  
    <Pattern>PC\.Tests\.UnitTests\*</Pattern>  
    <Type>Assembly</Type>  
    <IsRegex>True</IsRegex>  
    <IsInclude>False</IsInclude>  
  </Filter> 
  <Filter>
    <Pattern>*NHibernate*</Pattern>
    <Type>Assembly</Type>
    <IsRegex>True</IsRegex>
    <IsInclude>False</IsInclude>
  </Filter>

MethodCoverage View 15 SymbolCoverage 60 BranchCoverage 60

<!-- NDepend -->
<NDependPath>C:\Program Files\NDepend</NDependPath>
<NDependProjectFilePath>D:\ProductionBuilds\16a\NDepend\NDependProject.xml</NDependProjectFilePath>
<NDependInDirs>"D:\ProductionBuilds\16a\bin";"C:\Windows\Microsoft.NET\Framework\v2.0.50727";C:\Windows\Microsoft.NET\Framework\v3.5;</NDependInDirs>
<NDpendOutputDir>"D:\ProductionBuilds\16a\Tests\Output\NDepend"</NDpendOutputDir>
<NCoverOutputDir>"Tests\Output\Coverage"</NCoverOutputDir>

-->

As you can see (if you can get through the formatting issues) I am trying to exclude Repositories, Unit Tests and NHibernate code from the reporting, but these assemblies appear in the full coverage and symbol reports regardless of what I put in there.

I also don’t seem to be able to change the coverage thresholds from the default of 95%.

Any help would be appreciated!

Thanks,


RE: Report filters not applying

Great question.

On the filters, I think the issue is that you're using Regex filters rather than wildcard filters, so Repositories isn't valid. You'll want to change that filter to .Repositories., and so on for the other assembly matches.

On the satisfactory coverage side, I noticed in the script you pasted that you named the property 'satisfactorycoverage' but then accessed it as $(SatisfactoryCoverage). I think those variables are case sensitive in MSBuild. Does changing access to $(satisfactorycoverage) fix the issue?


RE: Report filters not applying

Thanks very much for the reply.

You nailed it regarding the 'SatisfactoryCoverage' property, it was indeed case sensitive.

As for the RegExp vs wildcards, I had to turn off the RegEx and just use the wildcards, like this:


PC.Tests.UnitTests*
Assembly
False
False

Too easy - thanks again!