Skip to content

Return two connected conditions inconsistent coverage #1334

Open
@manuelamateo

Description

@manuelamateo

When returning two logically connected conditions, then the branch and line coverages are not consistent. To reproduce this, certain conditions must be met:

  1. Return the result of two logically connected conditions (AND or OR)
  2. 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)

image

Activity

daveMueller

daveMueller commented on May 14, 2022

@daveMueller
Collaborator

Thanks for reporting this. 👍

daveMueller

daveMueller commented on May 19, 2022

@daveMueller
Collaborator

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

daveMueller commented on May 19, 2022

@daveMueller
Collaborator

What I additonally found out that this issue doesn`t occur with 3 connected conditions.
grafik

added
bugSomething isn't working
and removed
untriagedTo be investigated
on May 19, 2022
Bertk

Bertk commented on Sep 16, 2024

@Bertk
Collaborator

Please verify whether the problem still exists using the latest coverlet 6.0.2 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingstalewith reproIssue with repro

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @Bertk@manuelamateo@daveMueller

        Issue actions

          Return two connected conditions inconsistent coverage · Issue #1334 · coverlet-coverage/coverlet