> dotnet dotсover test

Important: This post is outdated. Please use the instructions from the dotCover documentation.

If you’ve got the idea of this post just by reading the title, you may skip the next paragraph and go right to the procedure.

We’re going to talk about the dotCover.exe console runner and a new way to run coverage analysis of unit tests. While the dotnet tool simplified running tests a long time ago (dotnet test in the working directory is enough), dotCover.exe still required you to specify a lot of arguments in order to run tests, like an absolute path to the dotnet.exe, path to a .dll with tests, and others. Too much to type, and moreover, there’s no guarantee the paths won’t change at some point. In 2018.2, we came up with a solution: the “dotnet” way to run tests under coverage analysis. All you need is to insert the dotсover argument to the original string:
dotnet dotсover test

So, this is how you can make it work (steps 1-4 are made only once per project):

  1. Go to nuget.org and find the dotCover.CommandLineTools package.
  2. Do NOT reference this package in your unit tests project. Instead, open its .csproj file and add the following line that contains the package name and the current version (2018.2 EAP03 or later):
    <DotNetCliToolReference Include="JetBrains.dotCover.CommandLineTools" Version="2018.2.0-eap03" />
  3. In the command line, go to the directory containing your unit tests project.
  4. Run dotnet restore
    This will download dotCover command line tools to your computer.
  5. Run tests with coverage analysis:
    dotnet dotсover test

Important notes:

  1. The suggested way of using the console runner is NOT a replacement but an addition to the good old dotCover.exe. You can still use it to analyze coverage if you want to.
  2. If you want to specify any argument you’ve used previously with dotCover.exe, you can do this by simply adding the dc prefix to the argument name. E.g., to specify a report type, use --dcReportType instead of --ReportType:
    dotnet dotсover test --dcReportType=XML
  3. You don’t have to specify whether you want to cover (a coverage snapshot is saved) or analyze (a human-readable report is saved). This is one more improvement in this release that also applies to dotCover.exe. Now, the --ReportType / --dcReportType is the only argument you should use: if it is specified, you’ll get a report of a certain type; if not, a regular coverage snapshot will be saved.
  4. If you configured dotCover.exe via an XML file and want to continue using it, simply specify a path to the file
    dotnet dotсover test --dcXML="C:\config\config.xml"
    All parameters in the XML file that are not applicable to the new runner will be ignored.

One more important thing: the updated runner doesn’t require any additional workarounds for getting coverage of long-running tests (> 100 ms).

All in all, dotnet dotсover test is the fastest and easiest way to analyze tests coverage from the command line. It’s already available in ReSharper Ultimate 2018.2 EAP, so why not check it out right now?

This entry was posted in How-To's and tagged , , , , . Bookmark the permalink.

43 Responses to > dotnet dotсover test

  1. Pingback: Dew Drop - August 1, 2018 (#2778) - Morning Dew

  2. anuraj says:

    I am getting an error like this – No executable found matching command “dotnet-dotCover”

  3. Adam says:

    I worth to also mansion is working only through cmd not PowerShell (at least on my PC)

  4. Josh says:

    Will this work on linux with dotnet core? Or is this still Windows only?

  5. Bernhard says:

    Having multiple test projects, we need to merge the output from dotnet-dotcover into 1 file. Is this possible with dotnet-dotcover or do we have to use dotcover directly (with merge command)?

  6. Richard says:

    May I asked when will be released next release with dot cover for Linux/Ubuntu? Some more specific horizon – a bit?

    • Alexey Totin says:

      Hi Richard,
      there will be no standalone dotCover for Linux/macOS. Only as a part of Rider. Currently, this is planned for 2019.1 but the date can move.

      • Daniel says:

        We need dotCover for our docker CI. Why won’t there be a standalone version?

        • Alexey Totin says:

          Hi Daniel,
          sorry for the confusion. By ‘standalone dotCover’ I meant a desktop application with GUI (the one we have on Windows). So, there will be no standalone dotCover on Linux/mac. But, there will be a command line tool, a counterpart of dotcover.exe. So, stay tuned.

  7. Riyas says:


    Can we use this for .net framework 4.7 unit test project? I have tried and I have received version not supported error

  8. Chris says:

    Obviously I’d like to run at the solution level, to run all tests in the solutions.
    How can I make dotnet dotCover work in the solution directory?

  9. Meghraj Mitkari says:

    JustMock =2017 R3
    When I am generating code coverage report, it not generating.
    It’s show’s status as “Coverage analysis is in progress…”

  10. Lee says:

    I tried to call ‘dotnet restore’.But command respons is always error message.
    Could you please tell me what is wrong .

    dotnet restore
    C:\Program Files\dotnet\sdk\2.1.507\NuGet.targets(114,5): error : Value cannot be null. [C:\Users\satom.INTERNAL\source\repos\SampleDotCoverConsoleApp\SampleDotCoverConsoleApp.sln]
    C:\Program Files\dotnet\sdk\2.1.507\NuGet.targets(114,5): error : Parameter name: key [C:\Users\satom.INTERNAL\source\repos\SampleDotCoverConsoleApp\SampleDotCoverConsoleApp.sln]

    ——- My Environment:
    OS: Windows10 pro 64bit 10.0.17134
    Microsoft Visual Studio Professional 2017
    Version 15.9.12
    Microsoft .NET Framework
    Version 4.7.03056
    —— What did I do.
    1. Create .NetFramework Console Solution.
    2.Add .NetFrameWork test Project.
    3.Edit Test Project csproj file.

  11. Lee says:

    Hi Alexey Totin.

    I got this.

    dotnet restore
    C:\Program Files\dotnet\sdk\2.1.507\NuGet.targets(114,5): error : Value cannot be null. [C:\Users\satom.INTERNAL\source\repos\SampleDotCoverConsoleApp\SampleDotCoverConsoleApp.sln]
    C:\Program Files\dotnet\sdk\2.1.507\NuGet.targets(114,5): error : Parameter name: key [C:\Users\satom.INTERNAL\source\repos\SampleDotCoverConsoleApp\SampleDotCoverConsoleApp.sln]

    I wrote at the beginning.

  12. Ranjithkumar Rajendran says:


    I have a solution with .net & .net core project. I need to get the code coverage by Sonarqube (Dotcover).
    Able to generate is separately but how to merge those two?

    Any suggesestion?


    • Alexey Totin says:

      Hi Ranjithkumar,
      sorry, could you please clarify what you’re trying to achieve? Do you want to merge a coverage snapshot from Sonarqube with the one from dotCover? If yes, it’s not possible. What’s the reason for using both Sonarqube and dotCover?

Leave a Reply to Daniel Cancel reply

Your email address will not be published. Required fields are marked *