Skip to content

Merging test coverage results when performing dotnet test solution.sln -p:CollectCoverage=true #334

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
PeterKnealeBizCover opened this issue Feb 3, 2019 · 3 comments
Labels
enhancement General enhancement request

Comments

@PeterKnealeBizCover
Copy link

Is it possible to merge the coverage results of all test projects in a solution
ie: Solution.sln contains multiple xunit test projects

dotnet test Solution.sln -p:CollectCoverage=true

The --merge-with parameter is mentioned in the below context but i dont know whether or if this can be applied to the above scenario

coverlet <ASSEMBLY> --target <TARGET> --targetargs <TARGETARGS> --merge-with "/path/to/result.json"
@PeterKnealeBizCover PeterKnealeBizCover changed the title Merging test coverage results with performing dotnet test solution.sln -p:CollectCoverage=true Merging test coverage results when performing dotnet test solution.sln -p:CollectCoverage=true Feb 3, 2019
@tonerdo
Copy link
Collaborator

tonerdo commented Feb 4, 2019

Coverlet doesn't currently support Solution wide executions. You'll need to run it for each project in the solution

@clairernovotny
Copy link
Contributor

clairernovotny commented Feb 19, 2019

The approach I describe in #177 should work. You'll need to use a tool like ReportGenerator to merge the xml files.

In my Directory.Build.targets file, I have this:

  <PropertyGroup>
    <IsTestProject>$(MSBuildProjectName.Contains('Test'))</IsTestProject>
  </PropertyGroup>

  <PropertyGroup Condition="'$(IsTestProject)' == 'true'">
    <UseSourceLink>true</UseSourceLink>
    <CoverletOutputFormat>cobertura</CoverletOutputFormat>
    <Exclude>[xunit.*]*</Exclude>
    <CoverletOutput>$(MSBuildThisFileDirectory)coverlet/raw/$(AssemblyName)/$(TargetFramework)/</CoverletOutput>
  </PropertyGroup>

It then creates a subdirectory for each assembly and target framework, enabling me to run dotnet test with a wildcard.

@MarcoRossignoli MarcoRossignoli added the enhancement General enhancement request label May 6, 2019
@MarcoRossignoli
Copy link
Collaborator

Tracked by #357

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement General enhancement request
Projects
None yet
Development

No branches or pull requests

4 participants