Skip to content

Commit fe05e6d

Browse files
authored
Merge pull request #10627 from fhnaseer/main
Adding docs for IncludeTestAssembly for code coverage runsettings
2 parents 930f8c4 + 875707c commit fe05e6d

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

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

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,29 @@ 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+
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`.
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+
142165
### Regular expressions
143166

144167
Include and exclude nodes use regular expressions, which aren't the same as wildcards. All matches are case-insensitive. Some examples are:
@@ -317,7 +340,8 @@ Included items must then not match any entries in the exclude list to remain inc
317340
<EnableDynamicNativeInstrumentation>True</EnableDynamicNativeInstrumentation>
318341
<!-- When set to True, instrumented binaries on disk are removed and original files are restored. -->
319342
<EnableStaticNativeInstrumentationRestore>True</EnableStaticNativeInstrumentationRestore>
320-
343+
<!-- When set to False, test assemblies will not be added to the coverage report. -->
344+
<IncludeTestAssembly>True</IncludeTestAssembly>
321345
</CodeCoverage>
322346
</Configuration>
323347
</DataCollector>

0 commit comments

Comments
 (0)