Search code examples
c#visual-studiocode-coveragerunsettings

Runsettings producing empty results


I am trying to configure my runsettings file to output only coverage for projects that have the name Adaptive in it, excluding tests.

I only want to look in the src directory local to the solution I am in.

So, totally stuck, for some reason this just gives me nothing in my code coverage file.

<CodeCoverage>
    <ModulePaths>
        <Include>
            <ModulePath>.*Adaptive.*\.dll</ModulePath>
        </Include>
        <Exclude>
            <ModulePath>.*Tests.*</ModulePath>
        </Exclude>
    </ModulePaths>
    <Attributes>
      <Exclude>
        <Attribute>^System\.Diagnostics\.CodeAnalysis\.ExcludeFromCodeCoverageAttribute$</Attribute>
      </Exclude>
    </Attributes>
</CodeCoverage>

What have I got wrong here?

local folder structure looks like this

Adaptive.sln
src\Adaptive.Something\Adaptive.Something.csproj
src\Adaptive.Nested\Adaptive.SomethingOtherThing\Adaptive.SomethingOtherThing.csproj
src\UnitTests.Adaptive.Something.csproj
tests\UnitTests.Adaptive.Something.csproj

(yes I know its a mess, but ill solve that issue another day)


Solution

  • It seems that there is a problem with the regular expression written.

    <ModulePath>.*Adaptive.*\.dll</ModulePath>
    

    should be changed to

    <ModulePath>.*Adaptive.*\.dll$</ModulePath>
    

    Include and exclude nodes use regular expressions. If there are errors in the regular expression (such as unescaped or mismatched parentheses), code coverage analysis will not run.