Phabricator:运行单元测试
问题描述:
我想为Phabricator编写自定义单元测试。Phabricator:运行单元测试
为此,我检查了文档Writing Unit Tests in Phabricator和./phabricator/src/infrastructure/testing/testcase/PhabricatorTrivialTestCase.php
创建的文件(使用琐碎phabricator测试用例),内容如下
class PhabricatorTrivialTestCase extends PhabricatorTestCase {
private $two;
public function willRunOneTest($test_name) {
// You can execute setup steps which will run before each test in this
// method.
$this->two = 2;
}
public function testAllIsRightWithTheWorld() {
$this->assertEqual(4, $this->two + $this->two, '2 + 2 = 4');
}
}
当我尝试运行它,我得到以下消息。
$ cd ./phabricator
$ arc unit src/infrastructure/testing/testcase/
No tests to run.
为什么我不能按照记录运行测试?有没有失踪?
答
终于想出了解决办法。
有些事情必须完成。
- 移动的测试文件的目录
./src/extensions/__tests__
(该文件夹必须是__tests__
) - 改名类
PhabricatorTrivialTestCase
到SomePhabricatorTrivialTestCase
(因为名字PhabricatorTrivialTestCase
测试已经存在) - 运行
arc liberate
(使SomeTrivialPhabricatorTestCase
供测试) - 提交更改
- 运行
arc unit --everything
(因为arc unit
返回“没有测试运行”,但arc unit --everything
作品