-
Notifications
You must be signed in to change notification settings - Fork 388
coverlet.msbuild 2.8.0 does not combine coverage when using MergeWith #678
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
Comments
The issue seem different...from this version coverlet generate different name for different target frameworks (old bug #177 we now append current framework moniker to avoid to override same file for different frameworks) so there is a possibility that you expect file merging between different project but now coverlet generate different file name 'C:\projects\httpclient-interception\artifacts\coverage.netcoreapp3.1.json' Maybe you expect only one file for all projects, is it correct? |
You've two project one with multiple target frameworks and the other with single https://github.com/justeat/httpclient-interception/blob/195c8a0f22423f23919f5043db024d75bd404bcd/src/HttpClientInterception/JustEat.HttpClientInterception.csproj#L13 If you simply change
You should use wilcard here https://github.com/justeat/httpclient-interception/blob/master/Build.ps1#L110 for report generator |
That's correct, as that's always been the behaviour previously. Thanks for explaining what's wrong and how to fix it - it's unfortunate that this breaking change to the behaviour was made in a minor release and/or didn't require a command-line flag to enable, though. |
Actually it was a bug 🙂 , if you check the issue related you can show what other users had to do as workaround. BTW let me know if it's all ok or need further help, sorry for the inconvenience Martin! |
Feel free to close if solved! |
I've gotten all my dependabot PRs fixed-up manually now - thanks for the assistance! |
And thanks for the advice we'll keep more attention on versioning (related to missing breaking behavior)! |
Just to clarify, the fix to get a single merged code coverage file using 2.8.0 in a multi-target framework unit test project is to change it so it targets a single framework. If that is the case, then we forgo the ability to unit test against all our target frameworks for the sake of a single coverage output. This is a bad outcome unless I'm misunderstanding the situation. My scenario is that I have test projects that use
in order to test a library that uses
Testing each target framework is important because the library has target framework specific code to validate. I am also sending the data to coveralls.io via GitHub actions which requires a single lcov file. 2.7.0 did work this way with
but as mentioned, 2.8.0 produces framework specific coverage files. Is there a way around this or do I have to choose between unit testing all target frameworks and code coverage metrics? |
Hi @roryprimrose, some question and thoughts:
I'd like to understand better your scenario and how you evaluate coverage. In case of merging different runtime how do you understand if the coverage is correct, decrease or increase?
Seem that coveralls.io support merging of multiple file https://docs.coveralls.io/parallel-build-webhook (btw I'm not a coverall experts) Thoughts: That said if this issue is a common issue we could add a new switch to preserve old(to me buggy and dangerous) behaviour for instance |
@MarcoRossignoli Thanks for the quick reply. I agree with you that your solution is technically correct and that the interpretation of coverage per framework should really be handled by the reporting tool. The current restriction is that the GitHub action for coveralls only accepts a single coverage file. Best I can tell they don't support multi-target coverage probably because it is a very .net thing to do. This does seem to be more a feature to provide in their space than coverlet merging the file. From a consumer perspective (ignoring the argument about detecting differing coverage analysis across target frameworks), I want to know what the holistic coverage is in which case a single file merged from all projects and target frameworks would be the desired outcome. This would then fit in nicely with the implementation of coveralls. I totally understand if this is something that doesn't progress. Given current available implementations, the options seem to be:
|
Yep, btw you'll lose all other new/future fixes
Ok they don't support multitarget but you can send more than one file with github action so you can use new coverlet version and have the old behaviour https://github.com/marketplace/actions/coveralls-github-action
I don't think that there is in the market such a report, because there aren't coverage file format that reports that information(the runtime) AFAIK, because as you said it's a pretty .net stuff, the best you can have it's a simple merge.
We don't want to lose any users, so the |
@roryprimrose found also this issue on coverallsapp coverallsapp/github-action#18 he resolved using Codecov https://docs.codecov.io/docs/merging-reports |
A reflection somewhat from the side here is that a lot of these issues around merging, thresholds etc comes from attempts to do coverage collection and analysis being as a single build step. A more unixy way of looking at it is that coverage gets collected during unit tests and written to files, and a separate tool is then run to analyse the coverage in whichever way the user needs. These tools can be combined with a script to get a single command line or build step to run. (Incidentially, this is how I use coverlet. A script runs all tests with the vstest collector to get coverage files, and then filter and combine in three different ways with reportgenerator to get slightly different views on the results. Partly this is because the early coverlet didn't support anything else, but also because I much prefer the fine-grained control I get this way.) A major new version av coverlet could look like this:
I think this would make it easier to use coverlet, and simplifying the code a lot. There would be less need for the more complex switches or command line flag combinations, as less common use cases (like the multi-target analysis in this issue or the Linux/Windows combined coverage) could be handled by scripting the coverlet command line tool. |
Eh...this is my "dream"...I'm working on vstest side to understand well what missing there, for instance fail on threshold, show data on console etc...that environment lack of some support, but ms team seem available to accomodate our needs.
This was also one of my idea...or some new "subcommand"
At the moment a lot of usage are on msbuild...maybe we could remove in 1/2-1 year announcing to community to move to collectors...but we need to be sure to support all needs. |
I mean that a 3.x version could be the vstest+coverlet cmd line only, with 2.x remaining as a legacy branch for those who wish to keep using coverlet as-is with msbuild . But no new merging or analysis features would be added to 2.x, all that would go into 3.x. Existing users aren't disrupted, but when they have new needs they have to take the effort of updating their toolchains to 3.x. |
At the moment we've three different version https://github.com/tonerdo/coverlet/blob/master/Documentation/Changelog.md#packages We could simply stop to release msbuild(flow only important core fix related to coverage alg and increase only fix part of semver 2.8.X) and move coverlet.console to 2.0(with new commands) and keep collectors with current versioning schema. |
Sorry, I used sloppy version numbers, forgetting that semver means that they don't necessarily go in sync in the different components. This direction would thus only be about coverlet.console 2.0? Which is better discussed in a new issue, if it is interesting to pursue it :) |
Yep
And yep 😄 will do |
Yes Azure DevOps also uses ReportGenerator internally to generate the coverage report. |
Dependabot pushed a number of updates to coverlet.msbuild to repositories I maintain just now to bump from 2.7.0 to 2.8.0, and for projects where code coverage is aggregated together using the
MergeWith
MSBuild property, the stats are no longer being combined.Here's such an example PR: justeattakeaway/httpclient-interception#171
This is causing builds to fail as their minimum coverage level specified by the
Threshold
MSBuild property is now no longer being met.The text was updated successfully, but these errors were encountered: