Skip to content

Commit 8af8d0c

Browse files
author
faisal
committed
Adding docs for IncludeTestAssembly,
1 parent 930f8c4 commit 8af8d0c

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

docs/test/customizing-code-coverage-analysis.md

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,31 @@ When static native instrumentation is enabled, Visual Studio will search and ins
139139

140140
::: moniker-end
141141

142+
### Include or exclude test assemblies
143+
144+
To include or exclude test assemblies from the coverage report, you can use the `<IncludeTestAssembly>` element in the `<Configuration>` section of your .runsettings file.
145+
146+
The following XML shows how to exclude test assemblies:
147+
148+
```xml
149+
<?xml version="1.0" encoding="utf-8"?>
150+
<!-- File name extension must be .runsettings -->
151+
<RunSettings>
152+
<DataCollectionRunSettings>
153+
<DataCollectors>
154+
<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">
155+
<Configuration>
156+
<IncludeTestAssembly>False</IncludeTestAssembly>
157+
...
158+
</Configuration>
159+
</DataCollector>
160+
</DataCollectors>
161+
</DataCollectionRunSettings>
162+
</RunSettings>
163+
```
164+
165+
In this example, setting `<IncludeTestAssembly>` to `False`` will exclude test assemblies from the code coverage report. If you want to include test assemblies, set it to True.
166+
142167
### Regular expressions
143168

144169
Include and exclude nodes use regular expressions, which aren't the same as wildcards. All matches are case-insensitive. Some examples are:
@@ -317,7 +342,8 @@ Included items must then not match any entries in the exclude list to remain inc
317342
<EnableDynamicNativeInstrumentation>True</EnableDynamicNativeInstrumentation>
318343
<!-- When set to True, instrumented binaries on disk are removed and original files are restored. -->
319344
<EnableStaticNativeInstrumentationRestore>True</EnableStaticNativeInstrumentationRestore>
320-
345+
<!-- When set to False, test assemblies will not be added to the coverage report. -->
346+
<IncludeTestAssembly>True</IncludeTestAssembly>
321347
</CodeCoverage>
322348
</Configuration>
323349
</DataCollector>

0 commit comments

Comments
 (0)