How to exclude migration folder from code coverage analyze result by runsettings file?
Asked Answered
O

1

3

I want exclude all migration classes from the code coverage analyze result. So I used the following code in codecoverage.runsettings file but code coverage analyze result is include migration namespace classes yet.

The namespace of migration classes is MySolution.Data.Migrations and they are in the Migrations directory of the MySolution.Data project.

Data Project > codecoverage.runsettings

<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
    <DataCollectionRunSettings>
        <DataCollectors>
            <DataCollector friendlyName="Code Coverage" uri="datacollector://Microsoft/CodeCoverage/2.0" assemblyQualifiedName="Microsoft.VisualStudio.Coverage.DynamicCoverageDataCollector, Microsoft.VisualStudio.TraceCollector, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
                <Configuration>
                    <CodeCoverage>
                          <!-- configuration elements -->
                          <Functions>
                              <Exclude>
                                  <Function>.*\.Data.Migrations\..**</Function>
                              </Exclude>
                          </Functions>
                    </CodeCoverage>
                </Configuration>
            </DataCollector>
        </DataCollectors>
    </DataCollectionRunSettings>
</RunSettings>
Operand answered 31/10, 2021 at 12:40 Comment(0)
O
4

I used the following code:

<!-- Exclude Migrations folder -->
<Exclude>
   <Function>^MySolution.Data\.Migrations\..*</Function>
</Exclude>
Operand answered 2/11, 2021 at 13:56 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.