2016-06-28 196 views
0

我想为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. 

为什么我不能按照记录运行测试?有没有失踪?

回答

0

终于想出了解决办法。

有些事情必须完成。

  • 移动的测试文件的目录./src/extensions/__tests__(该文件夹必须是__tests__
  • 改名类PhabricatorTrivialTestCaseSomePhabricatorTrivialTestCase(因为名字PhabricatorTrivialTestCase测试已经存在)
  • 运行arc liberate(使SomeTrivialPhabricatorTestCase供测试)
  • 提交更改
  • 运行arc unit --everything(因为arc unit返回“没有测试运行”,但arc unit --everything作品