Skip to content

Commit 7fff981

Browse files
fhnaseerfaisal
and
faisal
authored
Update dotnet-coverage docs. Adding uninstrument command (#43961)
* Update dotnet-coverage docs. Adding uninstrument command * fix, * Adding links to Micrsoft Code Coverage * fixing lint, --------- Co-authored-by: faisal <[email protected]>
1 parent 25dc499 commit 7fff981

File tree

3 files changed

+136
-33
lines changed

3 files changed

+136
-33
lines changed

docs/core/additional-tools/dotnet-coverage.md

+128-25
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ ms.topic: reference
1111
## Synopsis
1212

1313
```console
14-
dotnet-coverage [-h, --help] [--version] <command>
14+
dotnet-coverage <command> [-h, --help] [--version]
1515
```
1616

1717
## Description
@@ -49,6 +49,7 @@ dotnet tool install --global dotnet-coverage
4949
| [dotnet-coverage snapshot](#dotnet-coverage-snapshot) |
5050
| [dotnet-coverage shutdown](#dotnet-coverage-shutdown) |
5151
| [dotnet-coverage instrument](#dotnet-coverage-instrument) |
52+
| [dotnet-coverage uninstrument](#dotnet-coverage-uninstrument) |
5253

5354
## dotnet-coverage merge
5455

@@ -62,10 +63,12 @@ The `merge` command is used to merge several code coverage reports into one. Thi
6263

6364
```console
6465
dotnet-coverage merge
66+
<files>...
6567
[--remove-input-files]
6668
[-o|--output <output>] [-f|--output-format <output-format>]
67-
[-l|--log-file <log-file>] [-ll|--log-level <log-level>] [-?|-h|--help]
68-
<files>
69+
[-l|--log-file <log-file>] [-ll|--log-level <log-level>]
70+
[-dco|--disable-console-output] [--nologo]
71+
[-?|-h|--help]
6972
```
7073

7174
### Arguments
@@ -100,6 +103,14 @@ dotnet-coverage merge
100103

101104
Sets the log level. Supported values: `Error`, `Info`, and `Verbose`.
102105

106+
* **`-dco|--disable-console-output`**
107+
108+
Disables console output.
109+
110+
* **`--nologo`**
111+
112+
Do not display Code Coverage banner.
113+
103114
## dotnet-coverage collect
104115

105116
The `collect` command is used to collect code coverage data for any .NET process and its subprocesses. For example, you can collect code coverage data for a console application or a Blazor application. This command supports dynamic and static instrumentation. Static instrumentation is available on all platforms. You can specify files to be statically instrumented using `include-files` option. Dynamic instrumentation is available on Windows (x86, x64 and Arm64), Linux (x64), and macOS (x64). The command supports only .NET modules. Native modules are not supported.
@@ -114,11 +125,12 @@ The `collect` command will collect code coverage for the given process executed
114125

115126
```console
116127
dotnet-coverage collect
128+
<command> <args>...
117129
[-s|--settings <settings>] [-id|--session-id <session-id>]
118-
[-if|--include-files <include-files>] [-o|--output <output>]
119-
[-f|--output-format <output-format>] [-l|--log-file <log-file>]
120-
[-ll|--log-level <log-level>] [-?|-h|--help]
121-
<command> <args>
130+
[-if|--include-files <include-files>] [-o|--output <output>] [-f|--output-format <output-format>]
131+
[-l|--log-file <log-file>] [-ll|--log-level <log-level>]
132+
[-dco|--disable-console-output] [--nologo]
133+
[-?|-h|--help]
122134
```
123135

124136
#### Server Mode
@@ -129,9 +141,10 @@ The `collect` command hosts a server for code coverage collection. Clients can c
129141
dotnet-coverage collect
130142
[-s|--settings <settings>] [-id|--session-id <session-id>]
131143
[-sv|--server-mode] [-b|--background] [-t|--timeout]
132-
[-if|--include-files <include-files>] [-o|--output <output>]
133-
[-f|--output-format <output-format>] [-l|--log-file <log-file>]
134-
[-ll|--log-level <log-level>] [-?|-h|--help]
144+
[-if|--include-files <include-files>] [-o|--output <output>] [-f|--output-format <output-format>]
145+
[-l|--log-file <log-file>] [-ll|--log-level <log-level>]
146+
[-dco|--disable-console-output] [--nologo]
147+
[-?|-h|--help]
135148
```
136149

137150
### Arguments
@@ -186,6 +199,14 @@ dotnet-coverage collect
186199

187200
Sets the log level. Supported values: `Error`, `Info`, and `Verbose`.
188201

202+
* **`-dco|--disable-console-output`**
203+
204+
Disables console output.
205+
206+
* **`--nologo`**
207+
208+
Do not display Code Coverage banner.
209+
189210
## dotnet-coverage connect
190211

191212
The `connect` command is used to connect with the existing server and collects code coverage data for any .NET process and its subprocesses. For example, you can collect code coverage data for a console application or a Blazor application. The command supports only .NET modules. Native modules are not supported.
@@ -197,10 +218,11 @@ The `connect` command is used to connect with the existing server and collects c
197218

198219
```console
199220
dotnet-coverage connect
221+
<session> <command> <args>...
200222
[-b|--background] [-t|--timeout]
201-
[-l|--log-file <log-file>] [-ll|--log-level <log-level>] [-?|-h|--help]
202-
<session>
203-
<command> <args>
223+
[-l|--log-file <log-file>] [-ll|--log-level <log-level>]
224+
[-dco|--disable-console-output] [--nologo]
225+
[-?|-h|--help]
204226
```
205227

206228
### Arguments
@@ -235,6 +257,14 @@ dotnet-coverage connect
235257

236258
Sets the log level. Supported values: `Error`, `Info`, and `Verbose`.
237259

260+
* **`-dco|--disable-console-output`**
261+
262+
Disables console output.
263+
264+
* **`--nologo`**
265+
266+
Do not display Code Coverage banner.
267+
238268
## dotnet-coverage snapshot
239269

240270
Creates a coverage file for existing code coverage collection.
@@ -243,12 +273,14 @@ Creates a coverage file for existing code coverage collection.
243273

244274
```console
245275
dotnet-coverage snapshot
276+
<session>
246277
[-r|--reset]
247-
[-o|--output <output>]
248278
[-tn|--tag-name <tag-name>] [-tid|--tag-identifier <tag-identifier>]
279+
[-o|--output <output>]
249280
[-t|--timeout]
250-
[-l|--log-file <log-file>] [-ll|--log-level <log-level>] [-?|-h|--help]
251-
<session>
281+
[-l|--log-file <log-file>] [-ll|--log-level <log-level>]
282+
[-dco|--disable-console-output] [--nologo]
283+
[-?|-h|--help]
252284
```
253285

254286
### Arguments
@@ -263,10 +295,6 @@ dotnet-coverage snapshot
263295

264296
Clears existing coverage information after a coverage file is created.
265297

266-
* **`-o|--output <output>`**
267-
268-
Sets the code coverage report output file. If not provided, it's generated automatically with a timestamp.
269-
270298
* **`-tn|--tag-name <tag-name>`**
271299

272300
Creates a snapshot tag name in the coverage file with current coverage information. Tag-name and tag-identifier are mutually inclusive.
@@ -275,6 +303,10 @@ dotnet-coverage snapshot
275303

276304
Creates a snapshot tag identifier in the coverage file with current coverage information. Tag-name and tag-identifier are mutually inclusive.
277305

306+
* **`-o|--output <output>`**
307+
308+
Sets the code coverage report output file. If not provided, it's generated automatically with a timestamp.
309+
278310
* **`-t|--timeout`**
279311

280312
Timeout (in milliseconds) for interprocess communication between the client and the server.
@@ -287,6 +319,14 @@ dotnet-coverage snapshot
287319

288320
Sets the log level. Supported values: `Error`, `Info`, and `Verbose`.
289321

322+
* **`-dco|--disable-console-output`**
323+
324+
Disables console output.
325+
326+
* **`--nologo`**
327+
328+
Do not display Code Coverage banner.
329+
290330
## dotnet-coverage shutdown
291331

292332
Closes existing code coverage collection.
@@ -295,9 +335,11 @@ Closes existing code coverage collection.
295335

296336
```console
297337
dotnet-coverage shutdown
298-
[-t|--timeout]
299-
[-l|--log-file <log-file>] [-ll|--log-level <log-level>] [-?|-h|--help]
300338
<session>
339+
[-t|--timeout]
340+
[-l|--log-file <log-file>] [-ll|--log-level <log-level>]
341+
[-dco|--disable-console-output] [--nologo]
342+
[-?|-h|--help]
301343
```
302344

303345
### Arguments
@@ -320,6 +362,14 @@ dotnet-coverage shutdown
320362

321363
Sets the log level. Supported values: `Error`, `Info`, and `Verbose`.
322364

365+
* **`-dco|--disable-console-output`**
366+
367+
Disables console output.
368+
369+
* **`--nologo`**
370+
371+
Do not display Code Coverage banner.
372+
323373
## dotnet-coverage instrument
324374

325375
The instrument command is used to instrument binary on disk.
@@ -328,10 +378,12 @@ The instrument command is used to instrument binary on disk.
328378

329379
```console
330380
dotnet-coverage instrument
331-
[-s|--settings <settings>] [-id|--session-id <session-id>]
332-
[-o|--output <output>] [-l|--log-file <log-file>]
333-
[-ll|--log-level <log-level>] [-?|-h|--help]
334381
<input-file>
382+
[-s|--settings <settings>] [-id|--session-id <session-id>]
383+
[-o|--output <output>]
384+
[-l|--log-file <log-file>] [-ll|--log-level <log-level>]
385+
[-dco|--disable-console-output] [--nologo]
386+
[-?|-h|--help]
335387
```
336388

337389
### Arguments
@@ -362,6 +414,57 @@ dotnet-coverage instrument
362414

363415
Sets the log level. Supported values: `Error`, `Info`, and `Verbose`.
364416

417+
* **`-dco|--disable-console-output`**
418+
419+
Disables console output.
420+
421+
* **`--nologo`**
422+
423+
Do not display Code Coverage banner.
424+
425+
## dotnet-coverage uninstrument
426+
427+
The uninstrument command is used to restore original binary from the instrumented binary.
428+
429+
### Synopsis
430+
431+
```console
432+
Microsoft.CodeCoverage.Console uninstrument
433+
<input-file>
434+
[-s|--settings <settings>]
435+
[-l|--log-file <log-file>] [-ll|--log-level <log-level>]
436+
[-dco|--disable-console-output] [--nologo]
437+
[-?|-h|--help]
438+
```
439+
440+
### Arguments
441+
442+
* **`<input-file>`**
443+
444+
The input instrumented binary.
445+
446+
### Options
447+
448+
* **`-s|--settings <settings>`**
449+
450+
Sets the path to the XML code coverage settings.
451+
452+
* **`-l|--log-file <log-file>`**
453+
454+
Sets the log file path. When you provide a directory (with a path separator at the end), a new log file is generated for each process under analysis.
455+
456+
* **`-ll|--log-level <log-level>`**
457+
458+
Sets the log level. Supported values: `Error`, `Info`, and `Verbose`.
459+
460+
* **`-dco|--disable-console-output`**
461+
462+
Disables console output.
463+
464+
* **`--nologo`**
465+
466+
Do not display Code Coverage banner.
467+
365468
## Sample scenarios
366469

367470
## Collecting code coverage

docs/core/testing/unit-testing-platform-extensions-code-coverage.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@ This article list and explains all `Microsoft Testing Platform` extensions relat
1212

1313
You can use the code coverage feature to determine what proportion of your project's code is being tested by coded tests such as unit tests. To effectively guard against bugs, your tests should exercise or *cover* a large proportion of your code.
1414

15-
## Coverlet
16-
17-
There's currently no Coverlet extension, but you can use [Coverlet .NET global tool](https://github.com/coverlet-coverage/coverlet#net-global-tool-guide-suffers-from-possible-known-issue).
18-
1915
## Microsoft code coverage
2016

2117
Microsoft Code Coverage analysis is possible for both managed (CLR) and unmanaged (native) code. Both static and dynamic instrumentation are supported. This extension is shipped as part of [Microsoft.Testing.Extensions.CodeCoverage](https://nuget.org/packages/Microsoft.Testing.Extensions.CodeCoverage) NuGet package.
@@ -39,3 +35,7 @@ Microsoft Code Coverage provides the following options:
3935
| `--coverage-settings` | XML code coverage settings. |
4036

4137
For more information about the available options, see [settings](../additional-tools/dotnet-coverage.md#settings) and [samples](https://github.com/microsoft/codecoverage/tree/main/samples/Algorithms).
38+
39+
## Coverlet
40+
41+
There's currently no Coverlet extension, but you can use [Coverlet .NET global tool](https://github.com/coverlet-coverage/coverlet#net-global-tool-guide-suffers-from-possible-known-issue).

docs/core/tools/dotnet-test.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -278,16 +278,16 @@ Where `Microsoft.NET.Test.Sdk` is the test host, `xunit` is the test framework.
278278
dotnet test --logger trx
279279
```
280280

281-
- Run the tests in the project in the current directory, and generate a code coverage file (after installing [Coverlet](https://github.com/coverlet-coverage/coverlet/blob/master/Documentation/VSTestIntegration.md) collectors integration):
281+
- Run the tests in the project in the current directory, and generate a code coverage file using [Microsoft Code Coverage](https://github.com/microsoft/codecoverage/blob/main/README.md):
282282

283283
```dotnetcli
284-
dotnet test --collect:"XPlat Code Coverage"
284+
dotnet test --collect "Code Coverage"
285285
```
286286

287-
- Run the tests in the project in the current directory, and generate a code coverage file (Windows only):
287+
- Run the tests in the project in the current directory, and generate a code coverage file using [Coverlet](https://github.com/coverlet-coverage/coverlet/blob/master/README.md) (after installing [Coverlet](https://github.com/coverlet-coverage/coverlet/blob/master/Documentation/VSTestIntegration.md) collectors integration):
288288

289289
```dotnetcli
290-
dotnet test --collect "Code Coverage"
290+
dotnet test --collect:"XPlat Code Coverage"
291291
```
292292

293293
- Run the tests in the project in the current directory, and log with detailed verbosity to the console:

0 commit comments

Comments
 (0)