Skip to content

Count catch blocks as branches of the code #472

Open
@ekolis

Description

@ekolis

Installed product versions

  • Visual Studio: 2022 Professional
  • This extension: 1.1.229

Description

If my code contains a try/catch block, the catch is not counted as a branch of the code for branch coverage purposes. This can lead to a bizarre scenario where I have 100% branch coverage but the catch block is not covered. I think catch blocks should count as branches for this reason.

Steps to recreate

  1. Write some code with a try/catch block
  2. Write a test for that code that covers all the code except the catch block

Current behavior

Branch coverage reported as 100%

Expected behavior

Branch coverage should be reported as less than 100%, because the catch block was not tested.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions