Skip to content
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

Coverage is overwritten if the project has multiple target frameworks #177

Closed
SteveGilham opened this issue Aug 17, 2018 · 6 comments · Fixed by #636
Closed

Coverage is overwritten if the project has multiple target frameworks #177

SteveGilham opened this issue Aug 17, 2018 · 6 comments · Fixed by #636
Labels
bug Something isn't working driver-msbuild Issue related to msbuild driver good first issue Good for newcomers tenet-reporters Issue related to coverage output files(reporters) up-for-grabs Good issue for contributors

Comments

@SteveGilham
Copy link

If a system under test has multiple target frameworks, then

dotnet test /p:CollectCoverage=true

runs multiple coverage runs, overwriting the coverage output each time.

This is the equivalent of AltCover issue #31.

@tonerdo tonerdo added bug Something isn't working help wanted good first issue Good for newcomers labels Aug 22, 2018
@tonerdo
Copy link
Collaborator

tonerdo commented Aug 22, 2018

Thanks for reporting this. Will check it out

@joymon
Copy link

joymon commented Aug 29, 2018

+1
Same issue here. Due to overwriting its difficult. Work around seems having one project / target framework. But it beat the purpose of multi targeting.

@jherby2k
Copy link
Contributor

Workaround is just to run dotnet test with -f <framework>, grab the coverage.xml, then run it again with -f <other_framework>

@viceice
Copy link
Contributor

viceice commented Jan 24, 2019

Our workaround is to use merging and two output formats:

/p:CollectCoverage=true /p:CoverletOutput=./TestResults/ /p:CoverletOutputFormat=\"json,cobertura\" /p:MergeWith=./TestResults/coverage.json

@clairernovotny
Copy link
Contributor

I would suggest that the tfm be added to the output file name in this scenario, yielding multiple output files. ReportGenerator or something else can merge them then.

@clairernovotny
Copy link
Contributor

Here's another workaround --

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/$(AssemblyName)/$(TargetFramework)/</CoverletOutput>
  </PropertyGroup>

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working driver-msbuild Issue related to msbuild driver good first issue Good for newcomers tenet-reporters Issue related to coverage output files(reporters) up-for-grabs Good issue for contributors
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants