다음을 통해 공유


dotnet-coverage 코드 검사 유틸리티

이 문서의 적용 대상: ✔️ .NET Core 3.1 SDK 이상 버전

개요

dotnet-coverage [-h, --help] [--version] <command>

설명

dotnet-coverage 도구:

  • 실행 중인 프로세스의 코드 검사 데이터에 대한 플랫폼 간 컬렉션을 사용하도록 설정합니다.
  • 코드 검사 보고서의 플랫폼 간 병합을 제공합니다.

옵션

  • -h|--help

    명령줄 도움말을 표시합니다.

  • --version

    dotnet-coverage 유틸리티의 버전을 표시합니다.

설치

dotnet-coverage NuGet 패키지의 최신 릴리스 버전을 설치하려면 dotnet tool install 명령을 사용합니다.

dotnet tool install --global dotnet-coverage

명령

명령
dotnet-coverage merge
dotnet-coverage collect
dotnet-coverage connect
dotnet-coverage snapshot
dotnet-coverage shutdown
dotnet-coverage instrument

dotnet-coverage merge

merge 명령은 여러 코드 검사 보고서를 하나로 병합하는 데 사용됩니다. 이 명령은 모든 플랫폼에서 사용할 수 있습니다. 이 명령은 다음 코드 검사 보고서 형식을 지원합니다.

  • coverage
  • cobertura
  • xml

개요

dotnet-coverage merge
    [--remove-input-files]
    [-o|--output <output>] [-f|--output-format <output-format>]
    [-l|--log-file <log-file>] [-ll|--log-level <log-level>] [-?|-h|--help]
    <files>

인수

  • <files>

    입력 코드 검사 보고서.

옵션

  • --remove-input-files

    병합된 모든 입력 검사 보고서를 제거합니다.

  • -r, --recursive

    .NET 7 SDK 및 이전 버전에만 해당 하위 디렉터리에서 적용 범위 보고서를 검색합니다.

  • -o|--output <output>

    코드 검사 보고서 출력 파일을 설정합니다.

  • -f|--output-format <output-format>

    출력 파일 형식. 지원되는 값은 coverage, xmlcobertura입니다. 기본값은 coverage(Visual Studio에서 열 수 있는 이진 형식)입니다.

  • -l|--log-file <log-file>

    로그 파일 경로를 설정합니다. 디렉터리(끝에 경로 구분 기호 포함)가 제공될 때 분석 중인 각 프로세스에 대해 새 로그 파일이 생성됩니다.

  • -ll|--log-level <log-level>

    로그 수준을 설정합니다. 지원되는 값은 Error, InfoVerbose입니다.

dotnet-coverage collect

collect 명령은 .NET 프로세스와 해당 하위 프로세스에 대한 코드 검사 데이터 수집에 사용됩니다. 예를 들어 콘솔 애플리케이션 또는 Blazor 애플리케이션에 대한 코드 검사 데이터를 수집할 수 있습니다. 이 명령은 동적 및 정적 계측을 지원합니다. 정적 계측은 모든 플랫폼에서 사용할 수 있습니다. include-files 옵션을 사용하여 정적으로 계측할 파일을 지정할 수 있습니다. 동적 계측은 Windows(x86, x64 및 Arm64), Linux(x64) 및 macOS(x64)에서 사용할 수 있습니다. 이 명령은 .NET 모듈만 지원합니다. 원시 모듈은 지원되지 않습니다.

개요

collect 명령은 두 가지 모드로 실행될 수 있습니다.

명령 모드

collect 명령은 command 인수에 의해 실행된 지정된 프로세스에 대한 코드 검사를 수집합니다.

dotnet-coverage collect
    [-s|--settings <settings>] [-id|--session-id <session-id>]
    [-if|--include-files <include-files>] [-o|--output <output>]
    [-f|--output-format <output-format>] [-l|--log-file <log-file>]
    [-ll|--log-level <log-level>] [-?|-h|--help]
    <command> <args>

서버 모드

collect 명령은 코드 검사 모음을 위한 서버를 호스팅합니다. 클라이언트는 connect 명령을 통해 서버에 연결할 수 있습니다.

dotnet-coverage collect
    [-s|--settings <settings>] [-id|--session-id <session-id>]
    [-sv|--server-mode] [-b|--background] [-t|--timeout]
    [-if|--include-files <include-files>] [-o|--output <output>]
    [-f|--output-format <output-format>] [-l|--log-file <log-file>]
    [-ll|--log-level <log-level>] [-?|-h|--help]

인수

  • <command>

    코드 검사 데이터를 수집하는 명령입니다.

  • <args>

    명령에 대한 명령줄 인수입니다.

옵션

  • -s|--settings <settings>

    XML 코드 검사 설정의 경로를 설정합니다.

  • -id|--session-id <session-id>

    코드 검사 세션 ID를 지정합니다. 제공되지 않는 경우 이 도구는 임의의 GUID를 생성합니다.

  • -sv|--server-mode

    서버 모드에서 수집기를 시작합니다. 클라이언트는 connect 명령을 사용하여 서버에 연결할 수 있습니다.

  • -b|--background

    새 백그라운드 프로세스에서 코드 검사 모음 서버를 시작합니다. 클라이언트는 connect 명령을 사용하여 서버에 연결할 수 있습니다.

  • -t|--timeout

    클라이언트와 서버 간의 프로세스 간 통신에 대한 제한 시간(밀리초)입니다.

  • -if|--include-files <include-files>

    정적으로 계측할 파일 목록을 지정합니다.

  • -o|--output <output>

    코드 검사 보고서 출력 파일을 설정합니다.

  • -f|--output-format <output-format>

    출력 파일 형식. 지원되는 값은 coverage, xmlcobertura입니다. 기본값은 coverage(Visual Studio에서 열 수 있는 이진 형식)입니다.

  • -l|--log-file <log-file>

    로그 파일 경로를 설정합니다. 디렉터리(끝에 경로 구분 기호 포함)가 제공될 때 분석 중인 각 프로세스에 대해 새 로그 파일이 생성됩니다.

  • -ll|--log-level <log-level>

    로그 수준을 설정합니다. 지원되는 값은 Error, InfoVerbose입니다.

dotnet-coverage connect

connect 명령은 기존 서버에 연결하는 데 사용되며 모든 .NET 프로세스 및 해당 하위 프로세스에 대한 코드 검사 데이터를 수집합니다. 예를 들어 콘솔 애플리케이션 또는 Blazor 애플리케이션에 대한 코드 검사 데이터를 수집할 수 있습니다. 이 명령은 .NET 모듈만 지원합니다. 원시 모듈은 지원되지 않습니다.

참고 항목

명령은 Windows(x86, x64 및 Arm64), Linux(x64) 및 macOS(x64)에서 사용할 수 있는 모든 하위 프로세스에 대해 동적 계측을 사용합니다. .NET 모듈을 정적으로 계측해야 하는 경우 connect 명령을 실행하기 전에 instrument 명령(해당 세션 ID 옵션 포함)을 사용합니다.

개요

dotnet-coverage connect
    [-b|--background] [-t|--timeout]
    [-l|--log-file <log-file>] [-ll|--log-level <log-level>] [-?|-h|--help]
    <session>
    <command> <args>

인수

  • <session>

    collect 명령으로 호스트되는 서버의 세션 ID입니다.

  • <command>

    코드 검사 데이터를 수집하는 명령입니다.

  • <args>

    명령에 대한 명령줄 인수입니다.

옵션

  • -b|--background

    새로운 백그라운드 프로세스에서 클라이언트를 시작합니다.

  • -t|--timeout

    클라이언트와 서버 간의 프로세스 간 통신에 대한 시간 제한(밀리초).* -l|--log-file <log-file>

  • -l|--log-file <log-file>

    로그 파일 경로를 설정합니다. 디렉터리(끝에 경로 구분 기호 포함)가 제공될 때 분석 중인 각 프로세스에 대해 새 로그 파일이 생성됩니다.

  • -ll|--log-level <log-level>

    로그 수준을 설정합니다. 지원되는 값은 Error, InfoVerbose입니다.

dotnet-coverage snapshot

기존 코드 검사 모음에 대한 적용 범위 파일을 만듭니다.

개요

dotnet-coverage snapshot
    [-r|--reset]
    [-o|--output <output>]
    [-tn|--tag-name <tag-name>] [-tid|--tag-identifier <tag-identifier>]
    [-t|--timeout]
    [-l|--log-file <log-file>] [-ll|--log-level <log-level>] [-?|-h|--help]
    <session>

인수

  • <session>

    적용 범위 파일이 생성될 컬렉션의 세션 ID입니다.

옵션

  • -r|--reset <reset>

    적용 범위 파일이 만들어진 후 기존 적용 범위 정보를 지웁니다.

  • -o|--output <output>

    코드 검사 보고서 출력 파일을 설정합니다. 제공되지 않으면 타임스탬프와 함께 자동으로 생성됩니다.

  • -tn|--tag-name <tag-name>

    현재 적용 범위 정보를 사용하여 적용 범위 파일에 스냅샷 태그 이름을 만듭니다. 태그 이름과 태그 식별자는 상호 포함됩니다.

  • -tid|--tag-identifier <tag-identifier>

    현재 적용 범위 정보를 사용하여 적용 범위 파일에 스냅샷 태그 식별자를 만듭니다. 태그 이름과 태그 식별자는 상호 포함됩니다.

  • -t|--timeout

    클라이언트와 서버 간의 프로세스 간 통신에 대한 제한 시간(밀리초)입니다.

  • -l|--log-file <log-file>

    로그 파일 경로를 설정합니다. 디렉터리(끝에 경로 구분 기호 포함)가 제공될 때 분석 중인 각 프로세스에 대해 새 로그 파일이 생성됩니다.

  • -ll|--log-level <log-level>

    로그 수준을 설정합니다. 지원되는 값은 Error, InfoVerbose입니다.

dotnet-coverage shutdown

기존 코드 검사 컬렉션을 닫습니다.

개요

dotnet-coverage shutdown
    [-t|--timeout]
    [-l|--log-file <log-file>] [-ll|--log-level <log-level>] [-?|-h|--help]
    <session>

인수

  • <session>

    닫을 컬렉션의 세션 ID입니다.

옵션

  • -t|--timeout

    서버와의 프로세스 간 통신에 대한 제한 시간(밀리초)입니다.

  • -l|--log-file <log-file>

    로그 파일 경로를 설정합니다. 디렉터리(끝에 경로 구분 기호 포함)가 제공될 때 분석 중인 각 프로세스에 대해 새 로그 파일이 생성됩니다.

  • -ll|--log-level <log-level>

    로그 수준을 설정합니다. 지원되는 값은 Error, InfoVerbose입니다.

dotnet-coverage instrument

Instrument 명령은 디스크의 이진 파일을 계측하는 데 사용됩니다.

개요

dotnet-coverage instrument
    [-s|--settings <settings>] [-id|--session-id <session-id>]
    [-o|--output <output>] [-l|--log-file <log-file>]
    [-ll|--log-level <log-level>] [-?|-h|--help]
    <input-file>

인수

  • <input-file>

    입력 이진 파일입니다.

옵션

  • -s|--settings <settings>

    XML 코드 검사 설정의 경로를 설정합니다.

  • -id|--session-id <session-id>

    코드 검사 세션 ID를 지정합니다. 제공되지 않는 경우 이 도구는 임의의 GUID를 생성합니다.

  • -o|--output <output>

    출력 이진 파일에 대한 경로를 설정합니다. 지정하지 않으면 계측이 현재 위치에서 수행됩니다.

  • -l|--log-file <log-file>

    로그 파일 경로를 설정합니다. 디렉터리(끝에 경로 구분 기호 포함)가 제공될 때 분석 중인 각 프로세스에 대해 새 로그 파일이 생성됩니다.

  • -ll|--log-level <log-level>

    로그 수준을 설정합니다. 지원되는 값은 Error, InfoVerbose입니다.

샘플 시나리오

코드 검사 수집

다음 명령을 사용하여 .NET 애플리케이션(예: 콘솔 또는 Blazor)에 대한 코드 검사 데이터를 수집합니다.

dotnet-coverage collect dotnet run

종료 신호를 필요로 하는 애플리케이션의 경우Ctrl+C를 사용할 수 있으며, 계속해서 코드 검사 데이터를 수집할 수 있습니다. 인수의 경우 .NET 앱을 시작하는 모든 명령을 제공할 수 있습니다. PowerShell 스크립트를 예로 들 수 있습니다.

세션

메시지를 기다리고 응답을 보내는 .NET 서버에서 코드 검사 분석을 실행할 때 최종 코드 검사 결과를 얻기 위해 서버를 중지할 방법이 필요합니다. Ctrl+C는 로컬로 사용할 수 있지만 Azure Pipelines에서는 사용할 수 없습니다. 이러한 시나리오에서는 세션을 사용할 수 있습니다. 수집을 시작할 때 세션 ID를 지정한 다음, shutdown 명령을 사용하여 수집 및 서버를 중지할 수 있습니다.

예를 들어 D:\serverexample\server 디렉터리에 서버가 있고 D:\serverexample\tests 디렉터리에 테스트 프로젝트가 있다고 가정합니다. 테스트는 네트워크를 통해 서버와 통신합니다. 다음과 같이 서버에 대한 코드 검사 수집을 시작할 수 있습니다.

D:\serverexample\server> dotnet-coverage collect --session-id serverdemo "dotnet run"

세션 ID가 serverdemo로 지정되었습니다. 그러면 다음과 같이 테스트를 실행할 수 있습니다.

D:\serverexample\tests> dotnet test

세션 serverdemo에 대한 코드 검사 파일은 다음과 같이 현재 적용 범위로 생성될 수 있습니다.

dotnet-coverage snapshot --output after_first_test.coverage serverdemo

또한 다음과 같이 태그 옵션을 사용하여 스냅샷 태그를 적용 범위 파일에 추가할 수 있습니다.

dotnet-coverage snapshot --tag-name after_first_test --tag-identifier after_first_test serverdemo

마지막으로 세션 serverdemo와 서버를 다음과 같이 닫을 수 있습니다.

dotnet-coverage shutdown serverdemo

다음은 서버 측 전체 출력의 예입니다.

D:\serverexample\server> dotnet-coverage collect --session-id serverdemo "dotnet run"
SessionId: serverdemo
Waiting for a connection... Connected!
Received: Hello!
Sent: HELLO!
Waiting for a connection... Code coverage results: output.coverage.
D:\serverexample\server>

서버 및 클라이언트 모드

코드 범위 컬렉션은 서버-클라이언트 모드에서도 수행할 수 있습니다. 이 시나리오에서는 코드 검사 모음 서버가 시작되고 여러 클라이언트가 서버에 연결할 수 있습니다. 코드 검사는 모든 클라이언트에 대해 집합적으로 수집됩니다.

다음 명령을 사용하여 코드 검사 서버를 시작합니다.

dotnet-coverage collect --session-id serverdemo --server-mode

이 예에서는 서버에 대해 세션 ID가 serverdemo로 지정되었습니다. 클라이언트는 다음 명령을 사용하여 이 세션 ID를 사용하여 서버에 연결할 수 있습니다.

dotnet-coverage connect serverdemo dotnet run

마지막으로 다음 명령을 사용하여 세션 serverdemo와 서버를 닫을 수 있습니다.

dotnet-coverage shutdown serverdemo

서버 프로세스는 모든 클라이언트 및 종료에 대한 집합적인 코드 검사 보고서를 만듭니다.

다음은 서버 측 전체 출력의 예입니다.

D:\serverexample\server> dotnet-coverage collect --session-id serverdemo --server-mode
SessionId: serverdemo
// Server will be in idle state and wait for connect and shutdown commands
Code coverage results: output.coverage.
D:\serverexample\server>

다음은 클라이언트 쪽 전체 출력의 예입니다.

D:\serverexample\server> dotnet-coverage connect serverdemo ConsoleApplication.exe World
Hello World!!
D:\serverexample\server> dotnet-coverage connect serverdemo WpfApplication.exe
D:\serverexample\server> dotnet-coverage shutdown serverdemo
D:\serverexample\server>

또한 백그라운드 모드에서 서버와 클라이언트를 모두 시작할 수도 있습니다. 또 다른 프로세스가 백그라운드에서 시작되어 제어권을 사용자에게 다시 반환합니다.

다음은 백그라운드 서버 클라이언트 모드의 전체 출력 예입니다.

D:\serverexample\server> dotnet-coverage collect --session-id serverdemo --server-mode --background
D:\serverexample\server> dotnet-coverage connect --background serverdemo ConsoleApplication.exe World
D:\serverexample\server> dotnet-coverage connect --background serverdemo WpfApplication.exe
D:\serverexample\server> dotnet-coverage shutdown serverdemo
D:\serverexample\server>

관리되는 어셈블리에 대한 정적 코드 검사

dotnet-coverage 도구는 정적 계측을 사용하여 관리되는 어셈블리에 대한 코드 검사를 수집하는 데 사용할 수 있습니다. 이 검사에서는 세 가지 방법을 사용할 수 있습니다. 설명을 위해 간단한 C# 콘솔 애플리케이션이 있다고 가정해 보겠습니다.

D:\examples\ConsoleApp> dotnet run
Hello, World!

파일 포함 옵션 또는 구성과 함께 Collect 명령 사용

instrument 명령을 사용하지 않으려면 다음과 같이 --include-files 옵션을 사용하여 계측할 파일을 지정할 수 있습니다.

D:\examples\ConsoleApp> dotnet-coverage collect --include-files .\bin\Debug\net7.0\*.dll dotnet run
Microsoft (R) Code Coverage Command Line Tool (x64)
Copyright (c) Microsoft Corporation. All rights reserved.

SessionId: 57862ec0-e512-49a5-8b66-2804174680fc
Hello, World!
Code coverage results: output.coverage.

다음과 같이 구성을 사용하여 계측할 파일을 지정할 수도 있습니다.

<ModulePaths>
  <IncludeDirectories>
    <Directory>D:\examples\ConsoleApp\bin\Debug\net7.0</Directory>
  </IncludeDirectories>
</ModulePaths>

instrument 명령과 collect 명령 사용

이 경우 첫 번째 이진 파일은 다음과 같이 계측해야 합니다.

D:\examples\ConsoleApp> dotnet-coverage instrument .\bin\Debug\net7.0\ConsoleApp.dll
Microsoft (R) Code Coverage Command Line Tool (x64)
Copyright (c) Microsoft Corporation. All rights reserved.

Input file successfully instrumented.

그런 다음 다음과 같이 코드 검사를 수집할 수 있습니다.

D:\examples\ConsoleApp> dotnet-coverage collect .\bin\Debug\net7.0\ConsoleApp.exe
Microsoft (R) Code Coverage Command Line Tool (x64)
Copyright (c) Microsoft Corporation. All rights reserved.

SessionId: a09e6bef-ff64-4b5f-8bb8-fc495ebb50ba
Hello, World!
Code coverage results: output.coverage.

서버 모드에서 계측기 사용 및 명령 수집

이 경우 애플리케이션 실행과 검사 모음을 완전히 분리할 수 있습니다. 먼저 다음과 같이 이진 파일을 계측합니다.

D:\examples\ConsoleApp> dotnet-coverage instrument --session-id 73c34ce5-501c-4369-a4cb-04d31427d1a4 .\bin\Debug\net7.0\ConsoleApp.dll
Microsoft (R) Code Coverage Command Line Tool (x64)
Copyright (c) Microsoft Corporation. All rights reserved.

Input file successfully instrumented.

참고

애플리케이션이 외부 수집기에 데이터를 연결하고 제공할 수 있도록 하려면 이 시나리오에서 세션 ID를 사용해야 합니다.

두 번째 단계에서는 다음과 같이 검사 수집기를 시작해야 합니다.

D:\examples\ConsoleApp> dotnet-coverage collect --session-id 73c34ce5-501c-4369-a4cb-04d31427d1a4 --server-mode
Microsoft (R) Code Coverage Command Line Tool (x64)
Copyright (c) Microsoft Corporation. All rights reserved.

SessionId: 73c34ce5-501c-4369-a4cb-04d31427d1a4

그런 다음 다음과 같이 애플리케이션을 시작할 수 있습니다.

D:\examples\ConsoleApp> .\bin\Debug\net7.0\ConsoleApp.exe
Hello, World!

마지막으로 다음과 같이 수집기를 닫을 수 있습니다.

D:\examples\ConsoleApp> dotnet-coverage shutdown 73c34ce5-501c-4369-a4cb-04d31427d1a4
Microsoft (R) Code Coverage Command Line Tool (x64)
Copyright (c) Microsoft Corporation. All rights reserved.

설정

collect 명령을 사용할 때 파일에 설정을 지정할 수 있습니다. 설정 파일은 코드 검사 분석에서 일부 모듈이나 메서드를 제외하는 데 사용할 수 있습니다. 형식은 runsettings 파일 내의 데이터 수집기 구성과 같습니다. 자세한 내용은 코드 검사 분석 사용자 지정을 참조하세요. 예를 들면 다음과 같습니다.

<?xml version="1.0" encoding="utf-8"?>
<Configuration>
    <CodeCoverage>
        <!--
        Additional paths to search for .pdb (symbol) files. Symbols must be found for modules to be instrumented.
        If .pdb files are in the same folder as the .dll or .exe files, they are automatically found. Otherwise, specify them here.
        Note that searching for symbols increases code coverage run time. So keep this small and local.
        -->
        <SymbolSearchPaths>
            <Path>C:\Users\User\Documents\Visual Studio 2012\Projects\ProjectX\bin\Debug</Path>
            <Path>\\mybuildshare\builds\ProjectX</Path>
        </SymbolSearchPaths>

        <!--
        About include/exclude lists:
        Empty "Include" clauses imply all; empty "Exclude" clauses imply none.
        Each element in the list is a regular expression (ECMAScript syntax). See /visualstudio/ide/using-regular-expressions-in-visual-studio.
        An item must first match at least one entry in the include list to be included.
        Included items must then not match any entries in the exclude list to remain included.
        -->

        <!-- Match assembly file paths: -->
        <ModulePaths>
            <Include>
                <ModulePath>.*\.dll$</ModulePath>
                <ModulePath>.*\.exe$</ModulePath>
            </Include>
            <Exclude>
                <ModulePath>.*CPPUnitTestFramework.*</ModulePath>
            </Exclude>
            <!-- Additional directories from .NET assemblies should be statically instrumented: -->
            <IncludeDirectories>
                <Directory Recursive="true">C:\temp</Directory>
            </IncludeDirectories>
        </ModulePaths>

        <!-- Match fully qualified names of functions: -->
        <!-- (Use "\." to delimit namespaces in C# or Visual Basic, "::" in C++.)  -->
        <Functions>
            <Exclude>
                <Function>^Fabrikam\.UnitTest\..*</Function>
                <Function>^std::.*</Function>
                <Function>^ATL::.*</Function>
                <Function>.*::__GetTestMethodInfo.*</Function>
                <Function>^Microsoft::VisualStudio::CppCodeCoverageFramework::.*</Function>
                <Function>^Microsoft::VisualStudio::CppUnitTestFramework::.*</Function>
            </Exclude>
        </Functions>

        <!-- Match attributes on any code element: -->
        <Attributes>
            <Exclude>
            <!-- Don't forget "Attribute" at the end of the name -->
                <Attribute>^System\.Diagnostics\.DebuggerHiddenAttribute$</Attribute>
                <Attribute>^System\.Diagnostics\.DebuggerNonUserCodeAttribute$</Attribute>
                <Attribute>^System\.CodeDom\.Compiler\.GeneratedCodeAttribute$</Attribute>
                <Attribute>^System\.Diagnostics\.CodeAnalysis\.ExcludeFromCodeCoverageAttribute$</Attribute>
            </Exclude>
        </Attributes>

        <!-- Match the path of the source files in which each method is defined: -->
        <Sources>
            <Exclude>
                <Source>.*\\atlmfc\\.*</Source>
                <Source>.*\\vctools\\.*</Source>
                <Source>.*\\public\\sdk\\.*</Source>
                <Source>.*\\microsoft sdks\\.*</Source>
                <Source>.*\\vc\\include\\.*</Source>
            </Exclude>
        </Sources>

        <!-- Match the company name property in the assembly: -->
        <CompanyNames>
            <Exclude>
                <CompanyName>.*microsoft.*</CompanyName>
            </Exclude>
        </CompanyNames>

        <!-- Match the public key token of a signed assembly: -->
        <PublicKeyTokens>
            <!-- Exclude Visual Studio extensions: -->
            <Exclude>
                <PublicKeyToken>^B77A5C561934E089$</PublicKeyToken>
                <PublicKeyToken>^B03F5F7F11D50A3A$</PublicKeyToken>
                <PublicKeyToken>^31BF3856AD364E35$</PublicKeyToken>
                <PublicKeyToken>^89845DCD8080CC91$</PublicKeyToken>
                <PublicKeyToken>^71E9BCE111E9429C$</PublicKeyToken>
                <PublicKeyToken>^8F50407C4E9E73B6$</PublicKeyToken>
                <PublicKeyToken>^E361AF139669C375$</PublicKeyToken>
            </Exclude>
        </PublicKeyTokens>

        <EnableStaticManagedInstrumentation>True</EnableStaticManagedInstrumentation>
        <EnableDynamicManagedInstrumentation>True</EnableDynamicManagedInstrumentation>

    </CodeCoverage>
</Configuration>

코드 검사 보고서 병합

다음과 같이 a.coverageb.coverage를 병합하고 데이터를 merged.coverage에 저장할 수 있습니다.

dotnet-coverage merge -o merged.coverage a.coverage b.coverage

예를 들어 dotnet test --collect "Code Coverage"와 같은 명령을 실행하는 경우 검사 보고서는 임의의 GUID로 이름이 지정된 폴더에 저장됩니다. 이러한 폴더는 찾아서 병합하기 어렵습니다. 이 도구를 사용하면 다음과 같이 globbing 패턴을 사용하여 모든 프로젝트에 대한 모든 코드 검사 보고서를 병합할 수 있습니다.

dotnet-coverage merge -o merged.cobertura.xml -f cobertura **\*.coverage

위 명령은 현재 디렉터리와 모든 하위 디렉터리의 모든 검사 보고서를 병합하고 결과를 cobertura 파일에 저장합니다. Azure Pipelines에서 코드 검사 결과 게시 작업을 사용하여 병합된 cobertura 보고서를 게시할 수 있습니다.

merge 명령을 사용하여 코드 검사 보고서를 다른 형식으로 변환할 수 있습니다. 예를 들어 다음 명령은 이진 코드 검사 보고서를 XML 형식으로 변환합니다.

dotnet-coverage merge -o output.xml -f xml input.coverage

참고 항목