-
Notifications
You must be signed in to change notification settings - Fork 386
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
Instrumenting non used assemblies produces non existing branches (whith hits =0) in branch coverage. Lowering coverage when using /p:MergeWith #223
Comments
@pape77 I don't quite understand what the problem is. Naturally if you run the coverage under different contexts, the final output would be different. Can you perhaps share your project structure and what commands you run at each different stage |
@tonerdo I'll try to explain better:
I named my projects So for example when I run This is as expected. The problem is that this coverage file includes some branchs with hits = 0 that don't exist at all when running a particular coverlet command over As a result of the latest, when merging Codes to exec this are really simple:
and then compare that output file with coverage file for
With the pr at #225 what I do is don't instrument the dlls that are referenced in test projects and not used/tested at all (as in my case, in which i mock everything, but still have the reference because i use the project's classes, and because it's referenced in the project I'm actually testing) Here are the two files that I got generated with the commands above Coverage.json for Data.Tests: Methods like I think this is not ok, I've tried writing all kind of tests for those silly 2 methods and I couldn't get the branch that is marked with 0 hits in Application to pop in the Data coverage file even with 0 hits whatsoever Hopefully it's more clear now Note: I only made focus on Application and Data projects. But same happens for Api Project in my first comment of the issue, since it references Application and Data projects Note2: Note that the merging does work correctly but I just made a quick mention of it here since it's not part of the real issue i want to illustrate, if i run
the result file will be the merged one between these 2 projects. Problem being, since the second run produces branches with 0 hits that don't exist in the output of the first command line, the merged coverage file will indeed increment hits only in the branches that are in the first run. Making the global coverage for ProjectName.Data to decrease (since branches with 0 hits exist in the final, merged, output) |
In when trying to solve this (pr #225) i found a comment in the code that called my attention In |
@tonerdo have you had the chance to take a second look at this? Hope it's clear now |
@pape77 I think I get it now. I've noticed branch coverage reporting defaults to 0 when there are no branches, which shouldn't be the case. In terms of nothing being called I think I want to keep that default behaviour and I suggest you simply exclude the offending assembly |
@tonerdo I cannot exclude the assembly since it's being used by the classes at my other project . If you ment by command line param, again i can't since i run this for the whole solution in one line. But most importantly, the problem is not branch coverage defaulting to 0 if not covered. The problem is that the non used assembly is generating NON EXISTING branches, with coverage 0 which will never be covered by the actual tests in other projects and therefore not overrided when merging. This will make code coverage % to go down, not reflecting reality. That's why i want to exclude the assembly if nothing there is used, which... Make sense right? What's your reason for keeping it? |
@tonerdo you mean the /p:Exclude param then. I have to specify what to exclude and i cannot make a generic test run for all my projects if I do, which is my final goal (probably not the only one with it). |
@tonerdo One option could be adding a command line option param to exclude non used assemblies, if you really want to keep current behaviour as default. Wouldn't mind modifying my pr to do so. |
@tonerdo i updated my pr to add this as an option so default behaviour remains the same and fixes the issues for those who need to exclude non used files from coverage (#225) I got an error when doing some http post call for a vs 2015 test on app veyor. Probably if you re run it, it will work. |
Any news on this issue? I can't really tell my coworkers to use Coverlet in our builds if the coverage decreases in complex solutions where many project references are used. Our coverage will be lower numbers that don't make much sense, if I understand the issue correctly. Like pape77, we really insist on running our tests per solution and having good results without any manual setup in our builds. Thanks! |
@vlef i already gave up and forked away. If you use current coverlet, even more things that I don't care about (and maybe you don't either) gets into the report. Like certain external dlls i use. |
Thanks for the heads up! That is quite unfortunate, especially since even the official Microsoft docs link to Coverlet. |
Yep. I first wanted to exclude them by default. Then came with this option variable to keep the original behavior for whoever uses it. But no luck it seems 😢 |
@vlef if you plan to fork, you can copy the code from my original pr (so not the last commit but the first one). That will instrument only the dlls that you are touching with your tests. Although, i believe (as i mentioned) that now more things get instrumented even, not only the dlls with pdb files, but all. So you may have to remove a couple more things to make it look like the version i changed in my pr by that time |
@MarcoRossignoli why is it marked as feature request? As I understand this is a bug:
That is coverlet might detect fake branches. |
Is this issue still present?
I moved to feature because IIRW the idea is to remove module with no coverage to avoid to mess stats and to me is better add a feat like |
I don't know if this issue is still present, don't have repro, maybe @pape77 could comment? |
Hi guys, i forked away from this project since as @MarcoRossignoli knows, i made a pr for trying to fix this and other issues i have when running coverlet and trying to merge coverage when having tests in different projects.
Mainly problem 1 i tried to fix in an old pr, and i think it was fixing 1&2. You can try to repro this if you want, or ignore it. As you wish. Good luck! |
Thanks, I hoped you have some small repro that shows the "ghost branches" that you could share, I understand if you don't have it. |
I don't, i tested this with a repo of my company which I can't share |
how does it work currently for merging coverage in different test projects? I see no more merge option in the docs, is that done automatically? |
Hi @pape77 it works like in the past nothing changed on that side we're waiting to use new extension point from vstest plat #1015 (comment) https://github.com/coverlet-coverage/coverlet/blob/master/Documentation/DriversFeatures.md |
This issue is stale because it has been open for 90 days with no activity. |
@tonerdo When calculating the coverage from an assembly that's referenced in another test project, I get some differences on branch coverage than when i run the tests for the actual test project that is ment to test that assembly
But separately:
So my idea was to get:
Just noticed
ProjectName.Application
detects some branches of theProjectName.Data
thatProjectName.Data
does not detect when running the coverage for itself alone.Is this normal/possible?
The text was updated successfully, but these errors were encountered: