mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-24 05:28:18 +01:00
60 lines
2.1 KiB
Text
60 lines
2.1 KiB
Text
|
@title Arcanist User Guide: Code Coverage
|
||
|
@group userguide
|
||
|
|
||
|
Explains code coverage features in Arcanist and Phabricator.
|
||
|
|
||
|
= Using Coverage Features =
|
||
|
|
||
|
If your project has unit tests with coverage integration (see below for
|
||
|
instructions on setting it up), you can use "arc" to show coverage reports.
|
||
|
|
||
|
For example:
|
||
|
|
||
|
arc unit --detailed-coverage src/some/file.php
|
||
|
|
||
|
Depending on how your test engine is configured, this will run tests relevant
|
||
|
to ##src/some/file.php## and give you a detailed coverage report.
|
||
|
|
||
|
If the test engine enables coverage by default, it will be uploaded to
|
||
|
Differential and displayed in the right gutter when viewing diffs.
|
||
|
|
||
|
= Enabling Coverage for libphutil, Arcanist and Phabricator =
|
||
|
|
||
|
If you're contributing, libphutil, Arcanist and Phabricator support coverage if
|
||
|
you install Xdebug:
|
||
|
|
||
|
http://xdebug.org/
|
||
|
|
||
|
It should be sufficient to correctly install Xdebug; coverage information will
|
||
|
be automatically enabled.
|
||
|
|
||
|
= Building Coverage Support =
|
||
|
|
||
|
To add coverage support to a unit test engine, just call ##setCoverage()## when
|
||
|
building @{class@arcanist:ArcanistUnitTestResult} objects. Provide a map of
|
||
|
file names (relative to the working copy root) to coverage report strings.
|
||
|
Coverage report strings look like this:
|
||
|
|
||
|
NNNNNCCCNNNNNNNNCCCCCCNNNUUUNNNNN
|
||
|
|
||
|
Each line in the file is represented by a character. Valid characters are:
|
||
|
|
||
|
- **N** Not executable. This is a comment or whitespace which should be
|
||
|
ignored when computing test coverage.
|
||
|
- **C** Covered. This line has test coverage.
|
||
|
- **U** Uncovered. This line is executable but has no test coverage.
|
||
|
- **X** Unreachable. If your coverage analysis can detect unreachable code,
|
||
|
you can report it here.
|
||
|
|
||
|
This format is intended to be as simple as possible. A valid coverage result
|
||
|
might look like this:
|
||
|
|
||
|
array(
|
||
|
'src/example.php' => 'NNCNNNCNUNNNUNUNUNUNUNC',
|
||
|
'src/other.php' => 'NNUNNNUNCNNNUNUNCNCNCNU',
|
||
|
);
|
||
|
|
||
|
You may also want to filter coverage information to the paths passed to the
|
||
|
unit test engine. See @{class@arcanist:ArcanistPhutilTestCase} and
|
||
|
@{class@arcanist:PhutilUnitTestEngine} for an example of coverage integration
|
||
|
in PHP using Xdebug.
|