7

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?

julealgon
  • 7,072
  • 3
  • 32
  • 77

2 Answers2

2

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.

allen
  • 4,627
  • 1
  • 22
  • 33
  • I tried that too and it also didn't work. I think I tried every possible variation of exclusions containing the word AutoMapper with the same results. As for your suggestion about excluding everything, I don't think that will work since the exclusion list is processed _after_ the inclusion, thus nothing would be selected. – julealgon May 17 '15 at 04:47
  • @julealgon Have you also tried to add this `.*AutoMapper.*` to the `Exclude` section/element? – mguassa Dec 02 '15 at 22:49
  • i need exclude test project assembly ?how to do this – Karthic G Mar 23 '21 at 08:33
0

This may seem obvious, but did you update your build definition to include the .runsettings file? It's one thing to have CodeCoverage enabled in your build, but you have to provide the path to the .runsettings file.

Jim Roth
  • 399
  • 2
  • 9
  • 1
    Yes, I was setting the runsettings file correctly in the build definition back then. Thanks for the input, but you should probably consider asking these kinds of questions in comments instead of in an answer like this. – julealgon Dec 02 '15 at 14:29
  • 1
    My bad. Fairly new to answering things here. Thanks for the guidance. – Jim Roth Dec 03 '15 at 14:46