-
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
Removes the not instrumented/unused instrumenter results so coverage file doesn't get polluted with unused modules #225
Conversation
…file doesn't get polluted with unused modules
Codecov Report
@@ Coverage Diff @@
## master #225 +/- ##
==========================================
- Coverage 94.91% 94.21% -0.71%
==========================================
Files 15 15
Lines 1633 1641 +8
==========================================
- Hits 1550 1546 -4
- Misses 83 95 +12
Continue to review full report at Codecov.
|
I updated to add the exclusion of non called/instrumented files as an option, to keep current behaviour as default |
Not a fan of adding an option for every anomaly we encounter, it could lead to option bloat. I'm in the process of adding verbose logging functionality to coverlet, it'll spit out info when it encounters a non-called assembly and the user can choose to exclude it with the regular |
@tonerdo but again, the I'm not sure if the problem is completely clear to you, this is leading to wrong branch coverage % and it's affecting all coverages when merging if not solved anyway (maybe if you are lucky, those non called assemblies won't introduce extra non covered branches. Or maybe users don't notice it. I was lucky to spot it by chance, when I thought about why my coverage was so low on branch level). In addition to having to run a My aim is to have one line for running all tests with coverage (so |
@tonerdo I'm not a fan of adding options also, I just did beacause you mentioned you wanted to keep the original behaviour. Personally, I see no reason for not doing this, since it's ruining the coverage when merging and giving a false one. So the tool is not working properly, and that's not something that should be fixed using an |
Hi @pape77, sorry I seem to have let this slide. Will take a look and see if I can come up with an idea that works without having to add an extra option |
@tonerdo well the no extra options version of this was my original pr :P I just added it because you said you wanted to keep the original behaviour (for some reason I still don't get) |
@MarcoRossignoli I saw you marked this as enhancement, is something going to happen about this? |
@MarcoRossignoli I still notice the same behavior with current version of coverlet console (1.5.3) while running tests projects that reference some dlls that are not part of the code that we write ourselves. This dlls get included as part of the coverage (which will never be covered by tests of course, since they are downloaded from somewhere else). Example: My test bin folder looks like this, and when i run coverlet for this, i get:
as you see |
xunit will be escluded by default in next version #462 |
@tonerdo have you got opinions on this old PR? |
// Mark to be removed so no non used modules are included in coverage file? | ||
if (excludeNonCalledFiles) | ||
{ | ||
resultsToRemove.Add(result); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MarcoRossignoli this made the magic.
I just included a parameter for not doing this by default, because @tonerdo wanted to keep original behaviour (for some reason)
But this solved excluding any specific stuff that's not part of your code. Together with loop in line 245
You may want to try if it's still applicable. The referenced issue is probably now deprecated.
Current problem is more like coverlet trying to cover dlls that are not part of your code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At the moment I don't have a strong opinion, but I think that if we support this feature should be throught switch(like in this PR) because could be also useful understand why some module are not "tested", in big project someone could lose "the problem" of "disabled" tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if i can think an scenario in which you wouldn't see not tested modules which are part of your code.
Maybe if you don't test Api lvl ,then api.dll won't pop up and coverage will be higher. That's what you mean? but then you immediately don't see it covered in your coverage report or console output
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but then you immediately don't see it covered in your coverage report or console output
Yes but I think a scenario where I have tens of modules...if I see module with 0% it's immediatly clear that something went wrong(for instance temporary commented tests and not re-enabled) if you trim that result I could lose the issue, make sense?
@MarcoRossignoli Sounds like a monolith case. Makes sense in that case I guess. But worth to make a option parameter I think. For us who are really building microservices with couple of csprojs in it which are usually having the same structure |
Yep could be(I have this case 😄) btw a switch options would satisfy everyone, what do you think? |
That's why i did this pr this way :) Without fully understanding the reasons for keeping original behavior. |
Wait for @tonerdo opinion. |
@tonerdo i still need this for making use of coverlet for an entire organization across Europe :) (RTL). |
@tonerdo I think we could add a parameter to exclude empty hit files...but I wouldn't do that by "default" because could hide important issue. |
@tonerdo @MarcoRossignoli i was always fine with a parameter solution for this. Will make our life easier, instead of constantly syncing with the master coverlet version. I made some code duplication removal on my version as well which could have been a contribution to the main repo for example. |
@MarcoRossignoli would it be an idea to create a pr? Or is it a lot of work. |
The work is not small thing I'd like to be sure that @tonerdo and @petli agree with feature and avoid to waste time. |
@pape77 are you using your fork with this feat? We have enough thumbs up and yes we can use exclude but indeed it's not so comfortable to setup for every project in large solutions. |
@MarcoRossignoli we are using the VSTest version, i don't remember know if anything else. It's working for splitted test projects. I can look at the specifics when I'm at the office if it's useful for including it in the wiki or somewhere. |
You mean you're using VSTest Integration https://github.com/tonerdo/coverlet#vstest-integration-preferred-due-to-know-issue?
All version do the same thing, the core is the same(instrumentation) the only difference are supported parameters(for instance merge is not supported on vstest integration)
The core isn't changed so much, and the grid is not printing on vstest integration because is not supported at the moment on vstest side. On vstest coverlet is injected as a collectors and by design console output is captured and handled by vstest plat. To support console output we have to add a custom console logger #681 At the moment there is a drift in features supported by vstest integration and other driver(msbuild/.net tool), the roadmap is filling this gaps now that we're out with some stable versions https://github.com/tonerdo/coverlet/issues?q=is%3Aissue+is%3Aopen+label%3Adriver-collectors Also there is a new idea for the most requested cross feat, merging #683
Because the "issue" with "non used" asm is present yet for all drivers(msbuild/vstest/.net tool) and it's not related to only msbuild one. BTW if this is no more necessary feel free to close this PR! Thank's a lot for your help!Very appreciated! |
@MarcoRossignoli that is really strange because i remember using the latest msbuild and necore tool and it still did this include unused libraries thing. I'll check what we do now with vstest and come back with this |
Maybe in past you hit often https://github.com/tonerdo/coverlet/blob/master/Documentation/KnowIssues.md#1-vstest-stops-process-execution-earlydotnet-test that lead to that 0% because hit file wasn't flushed to disk before process kill, with vstest we're synched with plat and process won't be killed until we signal "our" flush. |
@MarcoRossignoli I have no clue. Anyhow, this is what we do (we use
runsettings look like this:
note that in the first snippet, we keep the latest merged file in |
And since we want to check the merged file for a threshold:
This may be useful for some other people that want to do this |
Strange mergewith has got some issue on vstest #662 (comment) how do you merge reports if file is generated in different folder for different projects? |
It's always taking the mergeWith param, so it's always creating a new file by merging with the one at |
Uh missed that piece I see good idea! |
@pape77 move to 1.2.0! |
For now I'll close this PR because seem no more useful. Feel free to re-open if needed. |
@tonerdo for when you have a sec to review :)
Sorry for the easy fix on the test though. I could not quickly think in a more clever way for fixing and testing that.
This addresses #223 in which I describe that sometimes unused instrumented results introduce new branches with hits=0 , polluting the final coverage and making the branch coverage to go down when it's not supposed to.
The actual tests that reference and use that instrumented result don't include such branches, so when the final result is produced using
MergeWith
, those branches will always remain with hits=0, lowering coverage, which is not correct.With this change, only actually used instrumented results will be included in the output coverage file. And when using
MergeWith
the output will be as expected and described in #223