Automatically running PHPUnit tests with Arcanist (Phabricator)

扶醉桌前 提交于 2020-01-02 05:38:29

问题


A "simple" question: how can I automatically run PHPunit tests with Arcanist?

According to the documentation I should first load a custom library. As stated here I should create a .arcconfig file and load the appropriate library.

So: I've create a dir "arc_libs" in my project and in the dir "src" I used arc liberate to generate the needed files. My config is now:

{
  "project.name" : "arc_libs",
  "phabricator.uri" : "https://phabricator.xxx.xxx.net/",
  "unit.engine" : "PhpunitTestEngine",
  "load" : ["arc_libs/src"]
}

The libary DOES get loaded because I can run arc unit

[matthijs@xx xxx]$ arc unit
No tests to run.

But as you can see there are no tests to run. We keep our tests in "project_root/tests" and as far as I understand the documentation I should create a __tests__ dir in "the module" (probably my arc_libs dir ?)

However I want to run my existing PHPunit test files, not new tests I need to create. I tried using a symlink etc but I cannot get it to work. Arcanist doesn't detect my tests.

So my question: How can I automatically run my EXISTING PHPunit tests with arcanist?

(note we use arc diff that should run arc unit automatically)


回答1:


The documentation you linked won't be very useful - it's aimed at Phabricator developers who want to test their libraries. There is some user-facing documentation for customising unit test tasks, but it's not great. Fortunately, it's quite easy to get Arcanist to run your project's unit tests using the included PhpunitTestEngine:

  1. Prepare a phpunit.xml file in your project root. This should be a standard PHPUnit configuration file. You can test this by running phpunit -c phpunit.xml.
  2. Add a phpunit_config option to your .arcconfig:

    {
      "phabricator.uri": "https://phabricator.xxx.xxx.net/",
      "unit.engine": "PhpunitTestEngine",
      "phpunit_config": "phpunit.xml"
    }
    
  3. Run arc unit to test it out.

Although user documentation is thin on the ground, the source code for PhpunitTestEngine has some comments and is fairly concise. If you run into problems, reading through the test engine code can help you track it down.




回答2:


$ arc unit --help

  unit [options] [paths]
  unit [options] --rev [rev]
      Supports: git, svn, hg
      Run unit tests that cover specified paths. If no paths are specified,
      unit tests covering all modified files will be run.

By default, arc lint and arc unit are meant to be used as part of a process of making changes, so by default it only acts on changed files. Odds are, you don't have any changed files. You probably want to specify some paths, or run arc unit --everything to run all tests.



来源:https://stackoverflow.com/questions/25893860/automatically-running-phpunit-tests-with-arcanist-phabricator

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!