~ubuntu-branches/ubuntu/wily/phabricator/wily

« back to all changes in this revision

Viewing changes to phabricator/src/docs/contributor/unit_tests.diviner

  • Committer: Package Import Robot
  • Author(s): Richard Sellam
  • Date: 2015-06-13 10:52:10 UTC
  • mfrom: (0.30.1) (0.29.1) (0.17.4) (2.1.9 sid)
  • Revision ID: package-import@ubuntu.com-20150613105210-5uirr7tvnk0n6e6y
Tags: 0~git20150613-1
* New snapshot release (closes: #787805)
* fixed typo in logrotate script (closes: #787645)

Show diffs side-by-side

added added

removed removed

Lines of Context:
9
9
framework. This document is aimed at project contributors and describes how to
10
10
use it to add and run tests in these projects or other libphutil libraries.
11
11
 
12
 
In the general case, you can integrate ##arc## with a custom unit test engine
 
12
In the general case, you can integrate `arc` with a custom unit test engine
13
13
(like PHPUnit or any other unit testing library) to run tests in other projects.
14
14
See @{article:Arcanist User Guide: Customizing Lint, Unit Tests and Workflows}
15
15
for information on customizing engines.
18
18
 
19
19
To add new tests to a libphutil, Arcanist or Phabricator module:
20
20
 
21
 
  - Create a ##__tests__/## directory in the module if it doesn't exist yet.
22
 
  - Add classes to the ##__tests__/## directory which extend from
 
21
  - Create a `__tests__/` directory in the module if it doesn't exist yet.
 
22
  - Add classes to the `__tests__/` directory which extend from
23
23
    @{class:PhabricatorTestCase} (in Phabricator) or
24
24
    @{class@arcanist:PhutilTestCase} (elsewhere).
25
 
  - Run ##arc liberate## on the library root so your classes are loadable.
 
25
  - Run `arc liberate` on the library root so your classes are loadable.
26
26
 
27
27
= Running Tests =
28
28
 
29
29
Once you've added test classes, you can run them with:
30
30
 
31
 
  - ##arc unit path/to/module/##, to explicitly run module tests.
32
 
  - ##arc unit##, to run tests for all modules affected by changes in the
 
31
  - `arc unit path/to/module/`, to explicitly run module tests.
 
32
  - `arc unit`, to run tests for all modules affected by changes in the
33
33
    working copy.
34
 
  - ##arc diff## will also run ##arc unit## for you.
 
34
  - `arc diff` will also run `arc unit` for you.
35
35
 
36
36
= Example Test Case =
37
37
 
76
76
    is reasonable.
77
77
  - Build a real database simulation layer (fairly complex).
78
78
  - Disable isolation for a single test by using
79
 
    ##LiskDAO::endIsolateAllLiskEffectsToCurrentProcess();## before your test
80
 
    and ##LiskDAO::beginIsolateAllLiskEffectsToCurrentProcess();## after your
 
79
    `LiskDAO::endIsolateAllLiskEffectsToCurrentProcess();` before your test
 
80
    and `LiskDAO::beginIsolateAllLiskEffectsToCurrentProcess();` after your
81
81
    test. This will disable isolation for one test. NOT RECOMMENDED.
82
82
  - Disable isolation for your entire test case by overriding
83
 
    ##getPhabricatorTestCaseConfiguration()## and providing
84
 
    ##self::PHABRICATOR_TESTCONFIG_ISOLATE_LISK => false## in the configuration
 
83
    `getPhabricatorTestCaseConfiguration()` and providing
 
84
    `self::PHABRICATOR_TESTCONFIG_ISOLATE_LISK => false` in the configuration
85
85
    dictionary you return. This will disable isolation entirely. STRONGLY NOT
86
86
    RECOMMENDED.