Skip to content

Add support for dotnet test ./**/*Tests*.dll --collect:"Code Coverage" #15351

@carlos-quintero

Description

@carlos-quintero

I have a solution with several .NET Framework 4.8 projects:

  • Class library projects, to be tested
  • Unit test projects
  • Integration test projects

Since the test projects are not .NET 10 (and cannot be since the class library projects are not .NET or .NET Standard 2.0), I cannot use the new Microsoft Testing Platform (MTP) but I have to keep using VSTest.

I would like to use dotnet test with these conditions:

  • Use dotnet test with VSTest (bridge mode)
  • Use dotnet test with compiled assemblies, not with .csproj files or with the .sln file
  • Use first dotnet test with unit tests assemblies
  • Use second dotnet test with integration tests assemblies
  • Use Microsoft code coverage (not Coverlet)

So, I would like to use command like these ones:

dotnet test ./**/*Unit.Tests.dll --collect:"Code Coverage"
dotnet test ./**/*Integration.Tests.dll --collect:"Code Coverage"

But I get error:

Data collection : Unable to find a datacollector with friendly name 'Code Coverage'.
Data collection : Could not find data collector 'Code Coverage'

Note

I am aware that all these variations work, but it is not what I want:

dotnet test --no-build --collect:"Code Coverage"

dotnet test TestProject1.Unit.Test.csproj --no-build --collect:"Code Coverage"
dotnet test TestProject2.Unit.Test.csproj --no-build --collect:"Code Coverage"

(notice that dotnet test **/*Unit.Test.csproj --no-build --collect:"Code Coverage" doesn't work because of the file globbing, which is not supported)

With Visual Studio 2022 Enterprise (which has support for code coverage), or with any edition of Visual Studio 2026 (all of them have support for code coverage):
vstest.console.exe ./**/*.Unit.Tests.dll --collect:"Code Coverage"
vstest.console.exe ./**/*.Integration.Tests.dll --collect:"Code Coverage"

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions