You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/test/customizing-code-coverage-analysis.md
+5-2Lines changed: 5 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -115,8 +115,6 @@ You can also specify different formats from the command-line by either specifyin
115
115
116
116
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.
117
117
118
-
You can enable native static instrumentation by enabling the preview feature **Code Coverage native static instrumentation** in **Tools > Options > Environment > Preview Features**.
119
-
120
118
You can also enable native static instrumentation in runsettings by adding `<EnableStaticNativeInstrumentation>True</EnableStaticNativeInstrumentation>` under `<CodeCoverage>` tag. Use this method for command line scenarios.
121
119
122
120
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
198
196
Copy this code and edit it to suit your needs.
199
197
200
198
::: moniker range=">=vs-2022"
199
+
201
200
```xml
202
201
<?xml version="1.0" encoding="utf-8"?>
203
202
<!-- File name extension must be .runsettings -->
@@ -207,6 +206,7 @@ Copy this code and edit it to suit your needs.
## Collect, connect, shutdown, merge, snapshot, and uninstrument commands
45
45
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).
47
47
48
48
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.
49
49
@@ -55,10 +55,12 @@ The instrument command is used to instrument native or managed binary on disk.
Sets the log level. Supported values: `Error`, `Info`, and `Verbose`.
91
93
94
+
***`-dco|--disable-console-output`**
95
+
96
+
Disables console output.
97
+
98
+
***`--nologo`**
99
+
100
+
Do not display Code Coverage banner.
101
+
92
102
## Static code coverage for C++ code
93
103
94
104
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:
> 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.
Copy file name to clipboardExpand all lines: docs/test/using-code-coverage-to-determine-how-much-code-is-being-tested.md
+12-7Lines changed: 12 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -78,7 +78,7 @@ Don't forget to run code coverage again after updating your code. Coverage resul
78
78
79
79
::: moniker range=">=vs-2022"
80
80
> [!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.
82
82
::: moniker-end
83
83
84
84
## Report in blocks or lines
@@ -90,7 +90,11 @@ You can also have the results displayed for lines by choosing **Add/Remove Colum
90
90
> 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.
91
91
92
92
::: 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.
94
98
95
99
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.
96
100
@@ -115,23 +119,23 @@ You can merge the results of several runs, for example from runs that use differ
115
119
116
120
-**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.
117
121
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.
119
123
120
124
The coverage coloring might be incorrect if the source code has changed since the *.coverage* file was generated.
121
125
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.
123
127
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.
125
129
126
130
## Merge results from different runs
127
131
128
132
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.
129
133
130
134
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.
131
135
132
-
Use **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 **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.
133
137
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.
0 commit comments