Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I force exclusion of certain assemblies from Code Coverage?

I'm trying to restrict the assemblies that get analyzed in the Code Coverage procedure in TFS by using a runsettings file, but some assemblies insist in being analyzed even if I exclude them explicitly.

This is my current runsettings file contents:

<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
  <!-- Configurations for data collectors -->
  <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>
            <ModulePaths>
              <Include>
                <ModulePath>.*Cloud4Mobile.*</ModulePath>
              </Include>
              <Exclude>
                <ModulePath>.*Tests.dll$</ModulePath>
                <ModulePath>.*TestUtilities.dll$</ModulePath>
              </Exclude>
            </ModulePaths>
            <CompanyNames>
              <Include>.*Mobiltec.*</Include>
            </CompanyNames>
          </CodeCoverage>
        </Configuration>
      </DataCollector>
    </DataCollectors>
  </DataCollectionRunSettings>
</RunSettings>

But when I run code coverage from Visual Studio to test this file, the analysis still shows me other assemblies that do not match my filter, like AutoMapper and CacheManager:

enter image description here

Note that my settings already exclude these assemblies by default, but even then I tried to explicitly exclude them to no avail, like this:

<Exclude>
  <ModulePath>^AutoMapper.dll$</ModulePath>
  ...
</Exclude>

I tried all variations of the regex there, from the less restrictive (using .*) to the most restrictive (like that example). These assemblies are polluting the report that I get on the TFS Build summary, and I'd like to remove them from the analysis. This is the full output that I was getting from TFS, which is obviously quite useless:

enter image description here

I managed to remove most of those with this .runsettings configuration file, but how do I make sure these outliers do not show there too? Why are they even showing in the first place, considering they were not matched by my include filters at all?

like image 737
julealgon Avatar asked May 15 '15 22:05

julealgon


Video Answer


1 Answers

My guess would be that the . in Automapper.dll is causing the problem. Could you try using

<Exclude>
  <ModulePath>.*AutoMapper\.dll$</ModulePath>

For your case of excluding everything by default you should just use .*\.dll in the modulepaths exclusions.

like image 84
allen Avatar answered Oct 04 '22 16:10

allen