Skip to content

Instantly share code, notes, and snippets.

@nunogoncalves
Forked from mnem/man xccov
Created May 20, 2018 14:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nunogoncalves/078f1cd1d14b861d6f376425a11276ec to your computer and use it in GitHub Desktop.
Save nunogoncalves/078f1cd1d14b861d6f376425a11276ec to your computer and use it in GitHub Desktop.
xccov(1) xccov(1)
NAME
xccov - view Xcode coverage data in human-readable or machine-parseable format.
SYNOPSIS
xccov view [--only-targets | --files-for-target target_name | --functions-for-file name_or_path]
[--json] report.xccovreport
xccov view [--file-list | --file path] archive.xccovarchive
DESCRIPTION
When tests are run with code coverage enabled, Xcode generates two files that contain its representa-
tion of coverage data. These are the coverage report, with extension xccovreport, and the coverage
archive, with extension xccovarchive. The coverage report contains line coverage percentages for each
target, source file, and function/method that has coverage information. The coverage archive contains
the raw execution counts for each file in the report. Using xccov, the contents of these files can be
viewed in either human-readable or machine-parseable format. These files are located in the
'Logs/Test' subdirectory of your Xcode project's DerivedData subfolder. Additionally, if the -result-
BundlePath flag is passed to xcodebuild(1), copies of the files are placed in the results bundle.
OPTIONS
--only-targets
Only view the list of targets.
--files-for-target target_name
Only view the source files in the target(s) with the given name.
--functions-for-file name_or_path
Only view the functions/methods for the file(s) with the given name or path. If supplying a
path, note that this is the path to the file when the coverage report was created, and the
file need not exist on disk.
--json View the data in JSON format (default is human readable text).
--file-list
When viewing an archive, list all of the files for which the archive contains coverage infor-
mation.
--file path
View the line and subrange execution counts stored in the archive for the file with the given
path. Note that this is the path to the file when the archive was created, and the file need
not exist on disk.
EXAMPLES
View all the data in a coverage report in human readable format:
xccov view C4518BEA-E0C1-4810-AFF9-23749EE19738.xccovreport
Name Coverage
------------------------------------------------------------------ ---------------
HelloWorld.app 57.89% (11/19)
/tmp/HelloWorld/HelloWorld/AppDelegate.m 50.00% (3/6)
-[AppDelegate applicationWillTerminate:] 0.00% (0/3)
-[AppDelegate applicationDidFinishLaunching:] 100.00% (3/3)
/tmp/HelloWorld/HelloWorld/ViewController.m 50.00% (5/10)
-[ViewController setRepresentedObject:] 0.00% (0/5)
-[ViewController viewDidLoad] 100.00% (5/5)
/tmp/HelloWorld/HelloWorld/main.m 100.00% (3/3)
main 100.00% (3/3)
HelloWorldTests.xctest 100.00% (21/21)
/tmp/HelloWorld/HelloWorldTests/HelloWorldTests.m 100.00% (21/21)
-[HelloWorldTests testExample] 100.00% (4/4)
-[HelloWorldTests testPerformanceExample] 100.00% (6/6)
-[HelloWorldTests tearDown] 100.00% (4/4)
__41-[HelloWorldTests testPerformanceExample]_block_invoke 100.00% (3/3)
-[HelloWorldTests setUp] 100.00% (4/4)
View all the data in a coverage report as JSON:
xccov view --json C4518BEA-E0C1-4810-AFF9-23749EE19738.xccovreport
{
"coveredLines": 32,
"lineCoverage": 0.80000000000000004,
"targets": [
{
"coveredLines": 11,
"lineCoverage": 0.57894736842105265,
"files": [
{
"coveredLines": 3,
"lineCoverage": 0.5,
"path": "tmpHelloWorldHelloWorldAppDelegate.m",
"functions": [
{
"coveredLines": 0,
"lineCoverage": 0,
"lineNumber": 22,
"executionCount": 0,
"name": "-[AppDelegate applicationWillTerminate:]",
"executableLines": 3
},
...
],
"name": "AppDelegate.m",
"executableLines": 6
},
...
],
"name": "HelloWorld.app",
"executableLines": 19,
"buildProductPath": "UsersSharedHelloWorld-ameficnolbeolwbhuqtjojyfcukrBuildProductsDebugHelloWorld.appContentsMacOSHelloWorld"
},
...
],
"executableLines": 40
}
View the list of files that have coverage information in the archive:
xccov view --file-list C4518BEA-E0C1-4810-AFF9-23749EE19738.xccovarchive/
/tmp/HelloWorld/HelloWorld/AppDelegate.m
/tmp/HelloWorld/HelloWorld/ViewController.m
/tmp/HelloWorld/HelloWorld/main.m
/tmp/HelloWorld/HelloWorldTests/HelloWorldTests.m
View the line and subrange execution counts for a file in the archive:
xccov view --file /tmp/HelloWorld/HelloWorldTests/HelloWorldTests.m C4518BEA-E0C1-4810-AFF9-23749EE19738.xccovarchive/
1: *
2: *
3: *
...
17: 2
18: 2
19: 2
...
31: *
32: 1
33: 1
34: 10 [
(1, 24, 1)
]
35: 10
36: 10 [
(6, 0, 1)
]
37: 1
The notation used here is line number : [line execution count | * if not executable] [[subrange [,
subrange]...]]. Subranges have the form (column, length, execution count).
Apple Inc. 2018 xccov(1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment