question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

/p:MergeWith does not merge but adds

See original GitHub issue

I’m testing using coverlet over a solution that has 3 test projects which i want to combine into a single .opencover.xml file

Since there’s currently no direct solution for this. What I tried to do is generate the coverage for one of the test projects, output its result into an “converage.json” file and then apply a MergeWith param in the following dotnet test commands to merge into that same json file and set the output format to opencover

Problem is, that since the first project(ProjectName.Api) includes other two as references (ProjectName.Application, ProjectName.Data), the report is generated as following:

Test run for /build/test/ProjectName.Api.Tests/bin/Debug/netcoreapp2.0/ProjectName.Api.Tests.dll(.NETCoreApp,Version=v2.0)

Results File: /results/_8e5df6e97674_2018-09-28_11_10_36.trx

Total tests: 15. Passed: 15. Failed: 0. Skipped: 0.
Test Run Successful.
Test execution time: 2.4645 Seconds

Calculating coverage result...
  Generating report '/results/coverage.json'

+----------------------+--------+--------+--------+
| Module               | Line   | Branch | Method |
+----------------------+--------+--------+--------+
|ProjectName.Api         | 24.4%  | 28.6%  | 33.3%  |
+----------------------+--------+--------+--------+
| ProjectName.Data        | 0%     | 0%     | 0%     |
+----------------------+--------+--------+--------+
|ProjectName.Application | 0%     | 0%     | 0%     |
+----------------------+--------+--------+--------+

So it includes two other coverages for the referenced projects with 0% coverage. This wouldn’t be a problem if /p:MergeWith param actually did a proper merge.

But when I run the next dotnet test (over the ProjectName.Application project) with the MergeWith param pointing to this recently generated coverage.json file, I get this:

Test run for /build/test/ProjectName.Application.Tests/bin/Debug/netcoreapp2.0/ProjectName.Application.Tests.dll(.NETCoreApp,Version=v2.0)

Starting test execution, please wait...
Results File: /results/_5d6c3e7d1c85_2018-09-28_11_10_47.trx

Total tests: 4. Passed: 4. Failed: 0. Skipped: 0.
Test Run Successful.
Test execution time: 1.7143 Seconds

Calculating coverage result...
  Generating report '/results/coverage.json'

+----------------------+--------+--------+--------+
| Module               | Line   | Branch | Method |
+----------------------+--------+--------+--------+
| ProjectName.Data        | 0%     | 0%     | 0%     |
+----------------------+--------+--------+--------+
| ProjectName.Application | 100%   | 60%    | 100%   |
+----------------------+--------+--------+--------+
| ProjectName.Api         | 24.4%  | 28.6%  | 33.3%  |
+----------------------+--------+--------+--------+
| ProjectName.Data        | 0%     | 0%     | 0%     |
+----------------------+--------+--------+--------+
| ProjectName.Application | 0%     | 0%     | 0%     |
+----------------------+--------+--------+--------+

So it just adds the recent coverage to the existing ones in coverage.json. Causing a duplicated coverage in ProjectName.Application and ProjectName.Data (because again, ProjectName.Application references ProjectName.Data, so it adds a coverage 0% report)

Any solutions to this? Or am I missusing something?

Or even a way for coverlet for avoid including referenced project coverage?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:28 (18 by maintainers)

github_iconTop GitHub Comments

6reactions
Dragon160commented, Apr 29, 2019

Any update here? I think it is quite a common use case to have more than one test project within the solution. A way to aggregate it so a single output would be really nice.

2reactions
tonerdocommented, Oct 17, 2018

Definitely sounds like a good idea @vlef @pape77. For starters I could just make the MergeWith parameter ignore when the specified file doesn’t exist and just assume it’s on a first run

Read more comments on GitHub >

github_iconTop Results From Across the Web

Customizer for mergeWith to not merge nested arrays
I found some resolving, and I understand that some lines no have sens, but it's work somehow : const customizer = (objValue, key)...
Read more >
Merged with does not always work - Bugs - Bubble Forum
I'm using merged with to get a limited list of items and append another list of items. The way I structured it, the...
Read more >
Git merge conflicts | Atlassian Git Tutorial
What is a git merge conflict? A merge conflict arises when Git cannot automatically resolve code differences between two commits. Learn more here....
Read more >
MERGE - Cypher Manual
The MERGE clause either matches existing node patterns in the graph and binds them or, if not present, creates new data and binds...
Read more >
How to Mail Merge with Attachments, Custom Subject & CC ...
Mail Merge leverages Microsoft Word, Excel, and Outlook. ... to do a mail merge with attachments, custom subjects, and cc/bcc (it's free to ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found