Skip to content

Code coverage reports a line as being covered when it isn't. #63194

@jasonbobier

Description

@jasonbobier

Description
With code coverage, lines that aren’t executed after a throw still have their hit count incremented.

Steps to reproduce

  1. Open the sample project
  2. Run testExample() unit test
  3. Notice in Throws.swift that the commented line shows 3 hits instead of 1

Expected behavior
The commented line should show 1 hit

Environment

  • Swift compiler version info: swift-driver version: 1.62.15 Apple Swift version 5.7.2 (swiftlang-5.7.2.135.5 clang-1400.0.29.51)
    Target: arm64-apple-macosx13.0

  • Xcode version info: Version 14.2 (14C18)

  • Deployment target: macOS 13.1

Also reported as: FB7656633

CoverageBug.zip

Metadata

Metadata

Assignees

Labels

bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.code coverageArea → source tooling: code coveragecompilerThe Swift compiler itselfcontrol transfer statementsFeature → statements: control transfer statementssource toolingArea: IDE support, SourceKit, and other source toolingstatementsFeature: statementsswift 5.9throwFeature → error handling: Throw statementsunexpected behaviorBug: Unexpected behavior or incorrect output

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions