How to exclude xunit test assemblies from Jetbrains dotCover coverage report running from command line

StackOverflow https://stackoverflow.com/questions/15656183

  •  29-03-2022
  •  | 
  •  

Вопрос

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

My Coverage Report My in depth 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!

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top