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

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

    Issue actions