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
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.
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)
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.
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With