Skip to content

swift test can not generate codecoverage json. #8189

Closed
@LeePepe

Description

@LeePepe

Is it reproducible with SwiftPM command-line tools: swift build, swift test, swift package etc?

  • Confirmed reproduction steps with SwiftPM CLI. The description text must include reproduction steps with either of command-line SwiftPM commands, swift build, swift test, swift package etc.

Description

swift test --enable-code-coverage can not generate codecoverage json.

Expected behavior

get the JSON file.

Actual behavior

The codecov dir only have two .profraw files, which one is starting with swift-testing and another is XCTest started.
And neither default.profdata nor *.json file in this folder.

Steps to reproduce

  1. generate Swift Package Manager by swift package init --name test
  2. add code in XCTests test file.
final class testTests: XCTestCase {
    func test() {
        let exp = expectation(description: "expdes")
    }
}
  1. swift test --enable-code-coverage to generate code coverage file.

If comment the let exp = expectation(description: "expdes"). The json file and default.profdata will show up.

Swift Package Manager version/commit hash

6.0

Swift & OS version (output of swift --version ; uname -a)

swift-driver version: 1.115.1 Apple Swift version 6.0.3 (swiftlang-6.0.3.1.10 clang-1600.0.30.1)
Target: arm64-apple-macosx15.0
Darwin litianpeiMacBook-Pro.local 24.2.0 Darwin Kernel Version 24.2.0: Fri Dec 6 19:01:59 PST 2024; root:xnu-11215.61.5~2/RELEASE_ARM64_T6000 arm64

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions