I'm running my CI build on TeamCity and I'm trying to get my coverage report to exclude my test dlls. Here's my exec command formatted for readability.
I've installed xUnit contrib dlls for dotCover 2.0 on all the team city agents
dotCover.exe
cover
/TargetExecutable="Path/To/XUnit/Runner"
/TargetArguments="My/Test/Assembly/Path"
/Output=coverage.dcvr
Which works and produces the following coverage report
As you can see from the second picture my Web.Tests dll is included in the coverage report. I've tried the following to filter out the test dll
dotCover.exe
cover
/TargetExecutable="Path/To/XUnit/Runner"
/TargetArguments="My/Test/Assembly/Path"
/Output=coverage.dcvr
/Filters=-:module=MyAssembly.Web.Tests;
/Filters=-:*.Tests
/Filters=-:MyAssembly.Web.Tests
/Filters=-:module=MyAssembly.Web.Tests
These generate the following xml in the logs
<DenyFilters>
<Item>
<AssemblyOrModuleFilter>MyAssembly.Web.Tests</AssemblyOrModuleFilter>
<ClassFilter>*</ClassFilter>
<FunctionFilter>*</FunctionFilter>
</Item>
</DenyFilters>
This however stops anything being reported at all
I'm using dotCover v2.0.425.72.
I think I may have found a limitation with dotcover and xunit here
Related Q's
How often is it the case when you write a question you find the answer shortly afterwards...
Having no filters results in the following xml in the logs
<AllowFilters>
<Item>
<AssemblyOrModuleFilter>*</AssemblyOrModuleFilter>
<ClassFilter>*</ClassFilter>
<FunctionFilter>*</FunctionFilter>
</Item>
</AllowFilters>
<DenyFilters />
Adding in the line /Filters=-:module=MyAssembly.Web.Tests
changes the xml to causing the no reporting of anything as the allow filters is killed off.
<AllowFilters />
<DenyFilters>
<Item>
<AssemblyOrModuleFilter>MyAssembly.Web.Tests</AssemblyOrModuleFilter>
<ClassFilter>*</ClassFilter>
<FunctionFilter>*</FunctionFilter>
</Item>
</DenyFilters>
So the fix is /Filters=+:module=*;class=*;function=*;-:module=MyAssembly.Web.Tests;
which gives the following xml
<AllowFilters>
<Item>
<AssemblyOrModuleFilter>*</AssemblyOrModuleFilter>
<ClassFilter>*</ClassFilter>
<FunctionFilter>*</FunctionFilter>
</Item>
</AllowFilters>
<DenyFilters>
<Item>
<AssemblyOrModuleFilter>MyAssembly.Web.Tests</AssemblyOrModuleFilter>
<ClassFilter>*</ClassFilter>
<FunctionFilter>*</FunctionFilter>
</Item>
</DenyFilters>
What a faff!