Skip to content

Commit ad44dd8

Browse files
Learn Build Service GitHub AppLearn Build Service GitHub App
authored andcommitted
Merging changes synced from https://github.com/MicrosoftDocs/visualstudio-docs-pr (branch live)
2 parents 3d69578 + 9753cfa commit ad44dd8

File tree

3 files changed

+37
-18
lines changed

3 files changed

+37
-18
lines changed

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,6 @@ You can also specify different formats from the command-line by either specifyin
115115

116116
In Visual Studio 2022 version 17.2, we added the option to instrument native binary statically (on disk). In previous versions, we supported only dynamic instrumentation, which was often not able to instrument methods. Static native instrumentation is more stable and it is recommended. Static native instrumentation requires enabling the [/PROFILE](/cpp/build/reference/profile-performance-tools-profiler) link option for all native projects for which you need code coverage collection.
117117

118-
You can enable native static instrumentation by enabling the preview feature **Code Coverage native static instrumentation** in **Tools > Options > Environment > Preview Features**.
119-
120118
You can also enable native static instrumentation in runsettings by adding `<EnableStaticNativeInstrumentation>True</EnableStaticNativeInstrumentation>` under `<CodeCoverage>` tag. Use this method for command line scenarios.
121119

122120
By default, dynamic native instrumentation is always enabled. If both static and dynamic instrumentation is enabled, Visual Studio tries to instrument your C++ code statically, but if this is not possible (for example, when the `/PROFILE` link option is not enabled), dynamic instrumentation will be used. You can fully disable dynamic native instrumentation in runsettings by adding `<EnableDynamicNativeInstrumentation>False</EnableDynamicNativeInstrumentation>` under `<CodeCoverage>`.
@@ -198,6 +196,7 @@ For more information about regular expressions, see [Use regular expressions in
198196
Copy this code and edit it to suit your needs.
199197

200198
::: moniker range=">=vs-2022"
199+
201200
```xml
202201
<?xml version="1.0" encoding="utf-8"?>
203202
<!-- File name extension must be .runsettings -->
@@ -207,6 +206,7 @@ Copy this code and edit it to suit your needs.
207206
<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">
208207
<Configuration>
209208
<CodeCoverage>
209+
<Format>coverage</Format>
210210
<!--
211211
Additional paths to search for .pdb (symbol) files. Symbols must be found for modules to be instrumented.
212212
If .pdb files are in the same folder as the .dll or .exe files, they are automatically found. Otherwise, specify them here.
@@ -322,9 +322,11 @@ Included items must then not match any entries in the exclude list to remain inc
322322
</DataCollectionRunSettings>
323323
</RunSettings>
324324
```
325+
325326
::: moniker-end
326327

327328
::: moniker range="vs-2019"
329+
328330
```xml
329331
<?xml version="1.0" encoding="utf-8"?>
330332
<!-- File name extension must be .runsettings -->
@@ -443,6 +445,7 @@ Included items must then not match any entries in the exclude list to remain inc
443445
</DataCollectionRunSettings>
444446
</RunSettings>
445447
```
448+
446449
::: moniker-end
447450

448451
## Related content

docs/test/microsoft-code-coverage-console-tool.md

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ Microsoft.CodeCoverage.Console is available in Visual Studio 2022 17.3 under the
2121
```console
2222
C:\Program Files\Microsoft Visual Studio\2022\Enterprise> Microsoft.CodeCoverage.Console --help
2323
Description:
24-
Dynamic code coverage tools.
24+
Code coverage tools.
2525

2626
Usage:
27-
codecoverage [command] [options]
27+
Microsoft.CodeCoverage.Console [command] [options]
2828

2929
Options:
3030
--version Show version information
@@ -37,13 +37,13 @@ Commands:
3737
merge <files> Merge coverage reports
3838
shutdown <session> Close existing code coverage collection.
3939
snapshot <session> Creates coverage file for existing code coverage collection.
40-
instrument <input-file> Instruments native binary.
41-
40+
instrument <input-file> Instruments native and managed binary.
41+
uninstrument <input-file> Restore original binary.
4242
```
4343

44-
## Collect, connect, shutdown, merge and snapshot commands
44+
## Collect, connect, shutdown, merge, snapshot, and uninstrument commands
4545

46-
The Microsoft.CodeCoverage.Console tool is extension to the [dotnet-coverage](/dotnet/core/additional-tools/dotnet-coverage) dotnet tool. The documentation for collect, connect, shutdown, merge, and snapshot commands can be found [here](/dotnet/core/additional-tools/dotnet-coverage).
46+
The Microsoft.CodeCoverage.Console tool is extension to the [dotnet-coverage](/dotnet/core/additional-tools/dotnet-coverage) dotnet tool. The documentation for collect, connect, shutdown, merge, snapshot, and uninstrument commands can be found [here](/dotnet/core/additional-tools/dotnet-coverage).
4747

4848
Microsoft.CodeCoverage.Console supports additional security features to enable collecting ASP.NET code coverage data from IIS. Additionally, the Microsoft.CodeCoverage.Console tool supports collecting code coverage for C++ code. The `instrument` command is specific to these scenarios.
4949

@@ -55,10 +55,12 @@ The instrument command is used to instrument native or managed binary on disk.
5555

5656
```console
5757
Microsoft.CodeCoverage.Console instrument
58-
[-s|--settings <settings>] [-id|--session-id <session-id>]
59-
[-o|--output <output>] [-l|--log-file <log-file>]
60-
[-ll|--log-level <log-level>] [-?|-h|--help]
6158
<input-file>
59+
[-s|--settings <settings>] [-id|--session-id <session-id>]
60+
[-o|--output <output>]
61+
[-l|--log-file <log-file>] [-ll|--log-level <log-level>]
62+
[-dco|--disable-console-output] [--nologo]
63+
[-?|-h|--help]
6264
```
6365

6466
### Arguments
@@ -89,6 +91,14 @@ Microsoft.CodeCoverage.Console instrument
8991

9092
Sets the log level. Supported values: `Error`, `Info`, and `Verbose`.
9193

94+
* **`-dco|--disable-console-output`**
95+
96+
Disables console output.
97+
98+
* **`--nologo`**
99+
100+
Do not display Code Coverage banner.
101+
92102
## Static code coverage for C++ code
93103

94104
The Microsoft.CodeCoverage.Console tool can be used to collect code coverage for C++ using static instrumentation. There are three different methods available that you can use. To demonstrate, let's assume we have a simple C++ console application (linked with the option [/PROFILE](/cpp/build/reference/profile-performance-tools-profiler)):
@@ -162,6 +172,7 @@ Then, start the application as follows:
162172
D:\ConsoleApplication\x64\Debug>.\ConsoleApplication.exe
163173
Hello World!
164174
```
175+
165176
> [!NOTE]
166177
> Instrumented native binary contains a reference to `static_covrun64.dll`. Make sure that this file is next to the instrumented binary or the directory where `static_covrun64.dll` is located is listed in the `Path` environment variable. The `collect` and `connect` commands are adding proper directories to `Path` automatically.
167178

docs/test/using-code-coverage-to-determine-how-much-code-is-being-tested.md

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ Don't forget to run code coverage again after updating your code. Coverage resul
7878

7979
::: moniker range=">=vs-2022"
8080
> [!TIP]
81-
> Starting in Visual Studio 2022 Update 2, you can enable faster code coverage test results by selecting **Tools > Options > Environment > Preview Features**, then selecting **Code coverage experience improvements**, and then restarting Visual Studio.
81+
> Starting in Visual Studio 2022 version 17.2, you can enable latest code coverage features by selecting **Tools > Options > Environment > Preview Features**, then selecting **Code coverage experience improvements**, and then restarting Visual Studio.
8282
::: moniker-end
8383

8484
## Report in blocks or lines
@@ -90,7 +90,11 @@ You can also have the results displayed for lines by choosing **Add/Remove Colum
9090
> A line of code can contain more than one code block. If this is the case, and the test run exercises all the code blocks in the line, it is counted as one line. If some but not all code blocks in the line are exercised, it is counted as a partial line.
9191
9292
::: moniker range=">=vs-2022"
93-
## Filter code coverage results
93+
## Code coverage results views
94+
95+
The **Code Coverage Results** window usually structures the report in the project/class/method hierarchy. You can change this to show the coverage on directory/file/method level.
96+
97+
- **To view the source Report**, select the **Configure Code Coverage Views** icon in the **Code Coverage Results** window. Then select **Source View** from the **Report Style** drop-down.
9498

9599
The **Code Coverage Results** window usually shows the result for the entire solution. The results can be filtered to show the results for only the files that have been updated in the current branch.
96100

@@ -115,23 +119,23 @@ You can merge the results of several runs, for example from runs that use differ
115119

116120
- **To view a previous set of results**, select it from the drop-down menu. The menu shows a temporary list that is cleared when you open a new solution.
117121

118-
- **To view results from a previous session**, choose **Import Code Coverage Results**, navigate to the **TestResults** folder in your solution, and import a *.coverage* file.
122+
- **To view results from a previous session**, choose **Import Results**, navigate to the **TestResults** folder in your solution, and import a *.coverage* file.
119123

120124
The coverage coloring might be incorrect if the source code has changed since the *.coverage* file was generated.
121125

122-
- **To make results readable as text**, choose **Export Code Coverage Results**. This generates a readable *.coveragexml* file, which you could process with other tools or send easily in mail. You can also select export formats such as Cobertura.
126+
- **To make results readable as text**, choose **Export Results**, select *.xml* as **Save as type**. This generates a readable *.xml* file, which you could process with other tools or send easily in mail. You can also select export formats such as Cobertura.
123127

124-
- **To send results to someone else**, send either a *.coverage* file or an exported *.coveragexml* file. They can then import the file. If they have the same version of the source code, they can see coverage coloring.
128+
- **To send results to someone else**, send either a *.coverage* file or an exported *.xml* file. They can then import the file. If they have the same version of the source code, they can see coverage coloring.
125129

126130
## Merge results from different runs
127131

128132
In some situations, different blocks in your code will be used depending on the test data. Therefore, you might want to combine the results from different test runs.
129133

130134
For example, suppose that when you run a test with input "2", you find that 50% of a particular function is covered. When you run the test a second time with the input "-2", you see in the coverage coloring view that the other 50% of the function is covered. Now you merge the results from the two test runs, and the report and coverage coloring view shows that 100% of the function was covered.
131135

132-
Use ![Icon for Merge button in Code Coverage window.](../test/media/codecoverage-mergeicon.png) **Merge Code Coverage Results** to do this. You can choose any combination of recent runs or imported results. If you want to combine exported results, you must import them first.
136+
Use ![Icon for Merge button in Code Coverage window.](../test/media/codecoverage-mergeicon.png) **Merge Results** to do this. You can choose any combination of recent runs or imported results. If you want to combine exported results, you must import them first.
133137

134-
Use **Export Code Coverage Results** to save the results of a merge operation.
138+
Use **Export Results** to save the results of a merge operation.
135139

136140
### Limitations in merging
137141

@@ -271,6 +275,7 @@ ExcludeSourceFromCodeCoverage(Exclusion4, L"*\\unittest1.cpp");
271275
#pragma managed(pop)
272276
273277
```
278+
274279
---
275280

276281
Use the following macros:

0 commit comments

Comments
 (0)