Changeset View
Changeset View
Standalone View
Standalone View
src/docs/contributor/unit_tests.diviner
@title Writing Unit Tests | @title Writing Unit Tests | ||||
@group developer | @group developer | ||||
Simple guide to libphutil, Arcanist and Phabricator unit tests. | Simple guide to Arcanist and Phabricator unit tests. | ||||
= Overview = | = Overview = | ||||
libphutil, Arcanist and Phabricator provide and use a simple unit test | Arcanist and Phabricator provide and use a simple unit test framework. This | ||||
framework. This document is aimed at project contributors and describes how to | document is aimed at project contributors and describes how to use it to add | ||||
use it to add and run tests in these projects or other libphutil libraries. | and run tests in these projects or other libphutil libraries. | ||||
In the general case, you can integrate `arc` with a custom unit test engine | In the general case, you can integrate `arc` with a custom unit test engine | ||||
(like PHPUnit or any other unit testing library) to run tests in other projects. | (like PHPUnit or any other unit testing library) to run tests in other projects. | ||||
See @{article:Arcanist User Guide: Customizing Lint, Unit Tests and Workflows} | See @{article:Arcanist User Guide: Customizing Lint, Unit Tests and Workflows} | ||||
for information on customizing engines. | for information on customizing engines. | ||||
= Adding Tests = | = Adding Tests = | ||||
To add new tests to a libphutil, Arcanist or Phabricator module: | To add new tests to a Arcanist or Phabricator module: | ||||
- Create a `__tests__/` directory in the module if it doesn't exist yet. | - Create a `__tests__/` directory in the module if it doesn't exist yet. | ||||
- Add classes to the `__tests__/` directory which extend from | - Add classes to the `__tests__/` directory which extend from | ||||
@{class:PhabricatorTestCase} (in Phabricator) or | @{class:PhabricatorTestCase} (in Phabricator) or | ||||
@{class@arcanist:PhutilTestCase} (elsewhere). | @{class@arcanist:PhutilTestCase} (elsewhere). | ||||
- Run `arc liberate` on the library root so your classes are loadable. | - Run `arc liberate` on the library root so your classes are loadable. | ||||
= Running Tests = | = Running Tests = | ||||
▲ Show 20 Lines • Show All 59 Lines • Show Last 20 Lines |