4

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)

Matthijs
  • 1,112
  • 2
  • 12
  • 28

2 Answers2

2

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.

Alex P
  • 5,942
  • 2
  • 23
  • 30
  • Thanks for your reply. We already use a separate phpunit.xml I changed the config to what you indicate but unfortunately arc still thinks there are no tests to run. I'd be happy to post our phpunit xml file but I don't think that is relevant, just running phpunit works like a charm. I'll look into the source code and see if there is anything that I can use. – Matthijs Sep 19 '14 at 11:40
  • Still no luck with this option, if anyone else can recommend something it would be greatly appreciated! – Matthijs Sep 26 '14 at 11:12
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.

mpeters
  • 21
  • 1