Open
Description
When returning two logically connected conditions, then the branch and line coverages are not consistent. To reproduce this, certain conditions must be met:
- Return the result of two logically connected conditions (AND or OR)
- The tests do not cover the case that the first condition is true (with OR), but cover both cases that the returned result ist true and false
I tried different implementations for this simple task and found four different code coverages. I'm not sure which one is the bug. Interestingly if instead of the first condition the second condition is never true, then the coverage of the different implementations are consistent.
See reproduction https://github.com/meggima/coverlet-reproductions TwoConditionsBranchCoverageReproduction.cs & TwoConditionsBranchCoverageReproductionFixture.cs (Version coverlet.msbuild 3.1.2)
Metadata
Metadata
Assignees
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
daveMueller commentedon May 14, 2022
Thanks for reporting this. 👍
daveMueller commentedon May 19, 2022
I debugged into this once for another issue #1279 that might be related but I couldn't find the issue back then. I debugged into this issue here and ended up at the same place. I think our algorithem that detects branches still has an issue somewhere here
CecilSymbolHelper.BuildPointsForConditionalBranch(...)
. Unfortunately this requires a lot of knowledge about IL and thus it's hard to find the issue.I'm currently short on time but I will dig into this again. Also every contribution and additional information that helps to fix this bug is highly appreciated.
daveMueller commentedon May 19, 2022
What I additonally found out that this issue doesn`t occur with 3 connected conditions.

Bertk commentedon Sep 16, 2024
Please verify whether the problem still exists using the latest coverlet 6.0.2 release.