Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to generate JSON coverage report with Xcode 11?

Tags:

xcrun

xcode11

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
like image 513
pipacs Avatar asked Sep 30 '19 13:09

pipacs


People also ask

How do I generate code coverage report in Xcode?

Reports navigator(View menu > Navigators > Reports or ⌘ - command + 9 ). After you open it, under the latest Test report, you should find a Coverage report, click on that, and it will contain the coverage information of that test run. You can find code coverage report under the Reports navigator.

What is Xccov?

xccov is a new command-line utility for inspecting the contents of Xcode coverage reports. It can be used to view coverage data in both human-readable and machine parseable format. See the man page for more information about the tool. ( Xcode 9.3b3)

What is slather coverage?

Slather is a framework that lets you “Generate test coverage reports for Xcode projects & hook it into CI.” Installation: Simply use the Terminal again and run the following command: gem install slather.


1 Answers

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)

like image 192
Carlos Ricardo Avatar answered Sep 20 '22 00:09

Carlos Ricardo