命令参考
dotCover 命令行工具提供以下命令:
cover - 对指定的应用程序、测试项目或任何
dotnet命令执行覆盖率分析。merge - 合并多个覆盖率快照。
report - 为指定的快照创建报告。
version - 将 dotCover 版本信息写入指定文件。
help - 显示命令行工具帮助。
您可以通过在控制台中输入 help 后跟命令名称来了解每个命令的详细信息。 所有命令(包括帮助)都有相应的快捷方式。 例如,要获取有关 analyse 命令的信息,您可以输入:
dotCover help cover
覆盖
dotCover cover — Run coverage analysis on a specified application or test project
=================================================================================
Usage:
dotCover cover <options> [-- <target arguments>]
dotCover cover @<args-file> [@<args-file2> ...] [<options>]
Description:
Runs coverage analysis for the specified executable, .NET test project, or any dotnet command.
If no executable is specified, dotCover will try to automatically run 'dotnet'.
Options:
--target-executable <path>
Path to the application or test runner to analyze.
If omitted, dotCover will auto-detect the 'dotnet' CLI.
--target-arguments <args>
Command-line arguments to pass to the target executable.
You can omit the parameter and specify them after a double dash: -- arg1 arg2
--target-working-directory <path>
Application working directory. By default, it's the target’s directory.
--snapshot-output <path>
Path to save the raw coverage snapshot ('.dcvr'). Autogenerated if omitted.
Filter options:
--exclude-assemblies <list>
Comma-separated list of assembly names to exclude from analysis. Wildcards (*) allowed, e.g., *.Tests
You can specify this option multiple times; all values will be combined.
--exclude-attributes <list>
Comma-separated list of fully qualified attribute names.
Code marked with these will be excluded, e.g., System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute
Wildcards (*) allowed. You can specify this option multiple times; all values will be combined.
--exclude-processes <list>
Comma-separated list of process names to ignore during analysis. Wildcards (*) allowed.
You can specify this option multiple times; all values will be combined.
Report options:
--json-report-output <path>
Paths to save formatted JSON report.
--json-report-covering-tests-scope <level>
Granularity for including covering tests in JSON reports: [none|assembly|type|method|statement]
--xml-report-output <path>
Paths to save formatted XML report.
--xml-report-covering-tests-scope <level>
Granularity for including covering tests in XML reports: [none|assembly|type|method|statement]
Advanced options:
--temporary-directory <path>
Directory for temporary files. By default, it's the system temp folder.
--use-api
Control the coverage session using the profiler API.
--no-ngen
Disable loading of NGen images during coverage.
--log-file <path>
Enable logging and specify the path to the log file.
Notes:
- You can use response files with the '@<args-file>' syntax to simplify command lines.
Examples:
dotCover cover --json-report-output report.json -- test
dotCover cover @args.txt
合并
dotCover merge — Combine multiple coverage snapshots into one
=============================================================
Usage:
dotCover merge <options>
dotCover merge @<args-file> [@<args-file2> ...] [<options>]
Description:
Merges two or more coverage snapshots (.dcvr files) into a single snapshot.
This is useful when coverage was collected in separate test runs (e.g., with different test frameworks or target platforms).
Options:
--snapshot-source <list>
Required. Comma-separated list of source snapshot files to merge.
--snapshot-output <path>
Path to save the merged snapshot (.dcvr). If omitted, a file name will be generated automatically.
Advanced options:
--temporary-directory <path>
Directory for temporary files. By default, it's the system temp folder.
--log-file <path>
Enable logging and specify the path to the log file.
Notes:
- You can use response files with the '@<args-file>' syntax to simplify command lines.
Examples:
dotCover merge --snapshot-source run1.dcvr,run2.dcvr --snapshot-output merged.dcvr
dotCover merge @merge-args.txt
报告
dotCover report — Generate a coverage report from a snapshot
============================================================
Usage:
dotCover report <options>
dotCover report @<args-file> [@<args-file2> ...] [<options>]
Description:
Creates a formatted report (XML or JSON) from a coverage snapshot (.dcvr).
Options:
--snapshot-source <path>
Required. Path to the coverage snapshot file (.dcvr).
--json-report-output <path>
Paths to save formatted JSON report.
--json-report-covering-tests-scope <level>
Granularity for including covering tests in JSON reports: [none|assembly|type|method|statement]
--xml-report-output <path>
Paths to save formatted XML report.
--xml-report-covering-tests-scope <level>
Granularity for including covering tests in XML reports: [none|assembly|type|method|statement]
Advanced options:
--log-file <path>
Enable logging and specify the path to the log file.
Notes:
- You can use response files with the '@<args-file>' syntax to simplify command lines.
Examples:
dotCover report --snapshot-source merged.dcvr --xml-report-output report.xml
dotCover report @report-args.txt
版本
dotCover version — Write the current dotCover version to a file
===============================================================
Usage:
dotCover version [options]
Description:
Write the current version to a specified file.
Options:
--text-output <path>
Path to save the version information as plain text.
Examples:
dotCover version
dotCover version --text-output version.txt
帮助
dotCover help — Show help for dotCover CLI commands
===================================================
Usage:
dotCover help [<command>]
Description:
Displays detailed help for a specific command.
Available commands:
cover Run coverage analysis on an application or test project
merge Combine multiple coverage snapshots into one
report Generate a coverage report from a snapshot
version Display the current dotCover version
help Show help on commands
Examples:
dotCover help cover
最后修改日期: 2025年 9月 27日