Show coverage information in Differential
Summary:
Render coverage information in the right gutter, if available.
We could render some kind of summary report deal too but this seems like a good
start.
Test Plan:
- Looked at diffs with coverage.
- Looked at diffs without coverage.
- Used inline comments, diff-of-diff, "show more", "show entire file", "show
generated file", "undo". Nothing seemed disrupted by the addition of a 5th
column.
Reviewers: btrahan, tuomaspelkonen, jungejason
Reviewed By: btrahan
CC: zeeg, aran, epriestley
Maniphest Tasks: T140
Differential Revision: https://secure.phabricator.com/D1527
2012-01-31 21:07:47 +01:00
|
|
|
@title Arcanist User Guide: Code Coverage
|
|
|
|
@group userguide
|
|
|
|
|
|
|
|
Explains code coverage features in Arcanist and Phabricator.
|
|
|
|
|
2012-08-10 21:00:40 +02:00
|
|
|
This is a configuration guide that helps you set up advanced features. If you're
|
|
|
|
just getting started, you don't need to look at this yet. Instead, start with
|
|
|
|
the @{article:Arcanist User Guide}.
|
|
|
|
|
|
|
|
Before you can configure coverage features, you must set up unit test
|
|
|
|
integration. For instructions, see @{article:Arcanist User Guide: Configuring
|
|
|
|
a New Project} and @{article:Arcanist User Guide: Customizing
|
|
|
|
Lint, Unit Tests and Workflows}.
|
|
|
|
|
Show coverage information in Differential
Summary:
Render coverage information in the right gutter, if available.
We could render some kind of summary report deal too but this seems like a good
start.
Test Plan:
- Looked at diffs with coverage.
- Looked at diffs without coverage.
- Used inline comments, diff-of-diff, "show more", "show entire file", "show
generated file", "undo". Nothing seemed disrupted by the addition of a 5th
column.
Reviewers: btrahan, tuomaspelkonen, jungejason
Reviewed By: btrahan
CC: zeeg, aran, epriestley
Maniphest Tasks: T140
Differential Revision: https://secure.phabricator.com/D1527
2012-01-31 21:07:47 +01:00
|
|
|
= 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
|
2015-05-31 02:07:45 +02:00
|
|
|
to `src/some/file.php` and give you a detailed coverage report.
|
Show coverage information in Differential
Summary:
Render coverage information in the right gutter, if available.
We could render some kind of summary report deal too but this seems like a good
start.
Test Plan:
- Looked at diffs with coverage.
- Looked at diffs without coverage.
- Used inline comments, diff-of-diff, "show more", "show entire file", "show
generated file", "undo". Nothing seemed disrupted by the addition of a 5th
column.
Reviewers: btrahan, tuomaspelkonen, jungejason
Reviewed By: btrahan
CC: zeeg, aran, epriestley
Maniphest Tasks: T140
Differential Revision: https://secure.phabricator.com/D1527
2012-01-31 21:07:47 +01:00
|
|
|
|
|
|
|
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:
|
|
|
|
|
2014-11-07 21:26:20 +01:00
|
|
|
http://xdebug.org/
|
Show coverage information in Differential
Summary:
Render coverage information in the right gutter, if available.
We could render some kind of summary report deal too but this seems like a good
start.
Test Plan:
- Looked at diffs with coverage.
- Looked at diffs without coverage.
- Used inline comments, diff-of-diff, "show more", "show entire file", "show
generated file", "undo". Nothing seemed disrupted by the addition of a 5th
column.
Reviewers: btrahan, tuomaspelkonen, jungejason
Reviewed By: btrahan
CC: zeeg, aran, epriestley
Maniphest Tasks: T140
Differential Revision: https://secure.phabricator.com/D1527
2012-01-31 21:07:47 +01:00
|
|
|
|
|
|
|
It should be sufficient to correctly install Xdebug; coverage information will
|
|
|
|
be automatically enabled.
|
|
|
|
|
|
|
|
= Building Coverage Support =
|
|
|
|
|
2015-05-31 02:07:45 +02:00
|
|
|
To add coverage support to a unit test engine, just call `setCoverage()` when
|
Show coverage information in Differential
Summary:
Render coverage information in the right gutter, if available.
We could render some kind of summary report deal too but this seems like a good
start.
Test Plan:
- Looked at diffs with coverage.
- Looked at diffs without coverage.
- Used inline comments, diff-of-diff, "show more", "show entire file", "show
generated file", "undo". Nothing seemed disrupted by the addition of a 5th
column.
Reviewers: btrahan, tuomaspelkonen, jungejason
Reviewed By: btrahan
CC: zeeg, aran, epriestley
Maniphest Tasks: T140
Differential Revision: https://secure.phabricator.com/D1527
2012-01-31 21:07:47 +01:00
|
|
|
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
|
2015-05-20 01:37:39 +02:00
|
|
|
unit test engine. See @{class@arcanist:PhutilTestCase} and
|
Show coverage information in Differential
Summary:
Render coverage information in the right gutter, if available.
We could render some kind of summary report deal too but this seems like a good
start.
Test Plan:
- Looked at diffs with coverage.
- Looked at diffs without coverage.
- Used inline comments, diff-of-diff, "show more", "show entire file", "show
generated file", "undo". Nothing seemed disrupted by the addition of a 5th
column.
Reviewers: btrahan, tuomaspelkonen, jungejason
Reviewed By: btrahan
CC: zeeg, aran, epriestley
Maniphest Tasks: T140
Differential Revision: https://secure.phabricator.com/D1527
2012-01-31 21:07:47 +01:00
|
|
|
@{class@arcanist:PhutilUnitTestEngine} for an example of coverage integration
|
2013-08-28 18:57:00 +02:00
|
|
|
in PHP using Xdebug.
|