Skip to content

Instantly share code, notes, and snippets.

@hnabbasi
Created September 26, 2019 15:49
Show Gist options
  • Save hnabbasi/bc174ba82ed26007d20a0fa3b2de16de to your computer and use it in GitHub Desktop.
Save hnabbasi/bc174ba82ed26007d20a0fa3b2de16de to your computer and use it in GitHub Desktop.
Unit Test Run Settings Template to include or exclude code for test coverage.
<?xml version="1.0" encoding="utf-8"?>
<!-- File name extension must be .runsettings -->
<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>
<!-- Match assembly file paths: -->
<ModulePaths>
<Include>
<!-- Only include MyProject.* assemblies -->
<ModulePath>.*myproject\..*</ModulePath>
</Include>
<Exclude>
<ModulePath>.*\.uitests.*</ModulePath>
<ModulePath>.*\.unittest.*</ModulePath>
</Exclude>
</ModulePaths>
<!-- Namespaces to include/exclude -->
<Functions>
<Exclude>
<Function>.*\.Views\..*</Function>
<Function>.*\.Annotations\..*</Function>
<Function>.*\.Resources\..*</Function>
</Exclude>
</Functions>
<!-- Match attributes on any code element: -->
<Attributes>
<Exclude>
<!--Don't forget "Attribute" at the end of the name -->
<Attribute>.*CustomExcludeFromCodeCoverageAttribute$</Attribute>
<Attribute>^System\.Diagnostics\.DebuggerHiddenAttribute$</Attribute>
<Attribute>^System\.Diagnostics\.DebuggerNonUserCodeAttribute$</Attribute>
<Attribute>^System\.Runtime\.CompilerServices.CompilerGeneratedAttribute$</Attribute>
<Attribute>^System\.CodeDom\.Compiler.GeneratedCodeAttribute$</Attribute>
<Attribute>^System\.Diagnostics\.CodeAnalysis.ExcludeFromCodeCoverageAttribute$</Attribute>
</Exclude>
</Attributes>
<!-- We recommend you do not change the following values: -->
<UseVerifiableInstrumentation>True</UseVerifiableInstrumentation>
<AllowLowIntegrityProcesses>True</AllowLowIntegrityProcesses>
<CollectFromChildProcesses>True</CollectFromChildProcesses>
<CollectAspDotNet>False</CollectAspDotNet>
</CodeCoverage>
</Configuration>
</DataCollector>
</DataCollectors>
</DataCollectionRunSettings>
</RunSettings>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment