How to generate JSON coverage report with Xcode 11?
Asked Answered
F

1

8

I've run unit tests from the command line like this:

xcodebuild \
    -resultBundlePath Example.xcresult \
    -workspace Example.xcworkspace \
    -scheme Example \
    -destination "platform=iOS Simulator,name=iPhone 8" \
    test

and now I'd like to get the coverage report as JSON, but xccov fails with Error: unrecognized file format:

xcrun xccov view --json Example.xcresult
Feuilleton answered 30/9, 2019 at 13:46 Comment(0)
S
20

According to Xcode 11 release notes you'll have to append --report too, so in your specific example:

xcrun xccov view --report --json Example.xcresult

The JSON format will be the same as the previous one.

Please read this thread from Honza Dvorsky (@czechboy0)

Staminody answered 2/10, 2019 at 5:47 Comment(1)
Also, Example.xcresult is your target now. Previously you had to drill down till the .xccovreport file and run the command for that bundle, but not anymore. So pay attention if you have some paths hardcoded to find the old .xccovport.Staminody

© 2022 - 2024 — McMap. All rights reserved.