-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Code Coverage do not match with Azure DevOps summary #13703
Comments
Same problem for our project - DevOps Pipeline shows 70% code coverage, but same tests in VS2019 show 95%. Not ideal to have to lower the threshold so much to make sure the builds are failed when the coverage is good. |
In my case it was the difference between "% of blocks covered" which is displayed in VS by default and "% of lines covered" which seems to be displayed in the build summary! |
@nk111 You should be able to change the columns in VS to see if the counts match up |
Yepp, your screenshot made me aware of this option actually ;) |
So, this error happens if you have one SUT but several Test Assemblies which run after each other. This error occurred for me when I had 2 different test runs - a Unit Test & then later an Integration Test. In this case, the percentage shown on the summary page was from the Unit Test only while on the detail page, it showed the accumulated coverage by Unit & Integration Test. |
Same problem here : multiple tests projects running after each other. |
Seems like this is a very common issue. Any update on this issue? I am seeing a coverage of 23% in summary in reality when the tests are executed in VS I have over 90% coverage. |
Same here, VS showing ~80% test coverage, Azure showing 50.51%. |
Everyone please make sure you are not comparing "% of lines covered" vs "% of blocks covered"! You can select more columns to be displayed in the VS Test results window! The Devops result means "% of lines covered" which might be lower than % of blocks covered displayed in VS by default! |
@nk111 Azure is wrong in both ways, see the following output on the UI vs what is in the actual report: |
@phanikmmsft - Any update on this issue? This is critical to CI/CD pipelines ensuring good code coverage. |
@v-pkoneti - pls look into this. |
I have noticed some similar problems. My pipeline run these tasks:
Please note that I set a variable This works well and pubblish tests and code coverage. In the "code coverage" tab I see this: And in the Summary I see the same %. So the Just for your knowledge... if I switch the test task to coverlet in this way:
This is what I see in the "code coverage" tab this time: Another try is with this:
I don't like that because doesn't populate the "Code coverage" tab on the build. I use this on another pipeline for obtain the Pull Request Diff coverage (I talk how to obtain both here microsoft/vstest#981 (comment) ) What I understood (please correct me if I am wrong): probably all these different methods to obtain code coverage use different filters. We need to find a (convenient) way to best set filters according to our needs. |
This issue is stale because it has been open for 180 days with no activity. Remove the stale label or comment on the issue otherwise this will be closed in 5 days |
@phanikmmsft or @nadesu Why is the actions bot trying to close an issue to which there has been no response from the engineering team? |
This is still an issue. DevOps still reports incorrect code coverage. @nadesu @v-pkoneti are there any plans to fix this? |
Hi @lzaromskis can I ask you what results you have launching Code Coverage on Visual Studio? (Test explorer > Analyze Code Coverage for All Tests). Can you put a screen here? |
@gioce90 I use Visual Studio Professional and it does not have code coverage. |
@lzaromskis there are FOSS packages and extensions you can get for visual studio pro and community like Coverlet, Run Coverlet Report and Fine Code Coverage. Also I saw it mentioned somewhere that async code causes a lot of these problems where the coverage doesn't report correctly. I'll see if I can find that again |
After some investigation, found that the issue is related with Report Generator. Need to set an environment variable in the pipeline: disable.coverage.autogenerate: 'true' |
Hi @lzaromskis , this was also my solution. You used Coverlet or MS's native Code Coverage? However, if you look carefully I had already written it in this thread :) (with native coverage... with coverlet I haven't tried much) I asked you if you could use VS code coverage because I wanted to check the reason for the mismatch. |
@gioce90 I used Coverlet. The mismatch from ReportGenerator was also because it counted generated C# files, so adding a file filter helped to get correct code coverage. |
That's weird because visual studio always used to include test dlls and sometimes third party dlls in the coverage. Had to make many test settings files to get them to stop including those unwanted targets. I guess they fixed it. |
This issue is stale because it has been open for 180 days with no activity. Remove the stale label or comment on the issue otherwise this will be closed in 5 days |
This issue should not be closed as this is still happening. The summary tab shows completely different numbers than the Code Coverage tab. And there is no way to validate the number shown on Summary, since it's not transparent at all how this is calculated. |
HI @Aculeo are you sure this is still happening? I'm collecting code coverage in two different ways (one for full coverage and the other for diff coverage) and to me the summary and the report seems to be fine. Results of my pipeline used for Diff coverage How you can see, they match. Results of my pipeline used for Full coverage How you can see, also in this case they match. This two builds that I have shown here are runs for the same Pull Request, so for the same code. If you see a little mismatch between the two "Line Coverage %", I think it is due the first pipeline include also test and third-party libraries, so is not a problem. |
I need to check again with a newer version of Azure DevOps Server, but currently we're still seeing this behavior |
Someone should reopen this if there is no validation of the fix :/ |
After some more troubleshooting, for me it is related to this bug: #13448 We are using the task PublishCodeCoverageResultsV1, and it has a known limitation that it cannot merge multiple coverage reports together. We have more than one test project, so this leads to weird behavior: Sometimes it picks the first coverage report, sometimes the second. We can see that in the log for the publish step:
Now PublishCodeCoverageResultsV2 supposedly has this fixed, as it will merge multiple reports together, but we do not have it yet in our Azure DevOps Server, so I cannot verify that. Will have to wait for this to trickle down with future updates. |
Can verify that the problem is fixed in PublishCodeCoverageResults@2. Happy coding! |
Required Information
The build summary page of Azure DevOps pipelines show a different code coverage (less code coverage) when compared to TRX file.
Question, Bug, or Feature?
Type: Bug
Enter Task Name: Azure DevOps build summary
list here (V# not needed):
https://github.com/microsoft/azure-pipelines-tasks/tree/master/Tasks/PublishTestResultsV2
Environment
Issue Description
Azure DevOps build summary shows different code coverage than what is show on Visual studio when we download the trx file.
From build summary
From VS when I downloaded the TRX file.
The task does not contain any Test filters, RunSettings - below is the configuration
The text was updated successfully, but these errors were encountered: