简体   繁体   English

使用HHVM运行phpunit测试(HipHop)

[英]Running phpunit tests using HHVM (HipHop)

I am trying to run PHPUnit unit tests via HHVM on a virtual Ubuntu 12.04 (64-bit Server) install. 我试图在虚拟Ubuntu 12.04(64位服务器)安装上通过HHVM运行PHPUnit单元测试。 The tests usually run using a phpunit.xml file located in my tests directory, which includes a bootstrap file to handle autoloading, and the tests run fine on an ordinary php install. 测试通常使用位于我的tests目录中的phpunit.xml文件运行,该文件包含一个用于处理自动加载的引导文件,并且测试在普通的php安装上运行良好。 However, I keep getting: 但是,我一直在:

HipHop Fatal error: File not found: File/Iterator/Autoload.php in /usr/share/php/PHPUnit/Autoload.php on line 64

When running: 运行时:

hhvm -f /usr/bin/phpunit /path/to/my/testsDirectory/SomeTest.php

And I haven't been able to figure out how to run phpunit under hhvm using a bootstrap or config file... Any help would be appreciated. 我还没有弄清楚如何使用bootstrap或配置文件在hhvm下运行phpunit ...任何帮助将不胜感激。

HHVM 2.4+ HHVM 2.4+

HHVM 2.4.0 was just released and it came with full phpunit support! HHVM 2.4.0刚刚发布 ,它提供了完整的phpunit支持! Just give the full path to phpunit binary, like this: 只需给出phpunit二进制文件的完整路径,如下所示:

$ hhvm /usr/bin/phpunit

Cheers! 干杯!


HHVM 2.3 HHVM 2.3

Tested this step by step guide from HHVM wiki and it works. 从HHVM wiki测试了这个一步一步的指南,它的工作原理。 Here is a simplified guide: 这是一个简化的指南:

On your project, add the following entries to your composer.json file: 在项目中,将以下条目添加到composer.json文件中:

"require-dev": {
    "phpunit/phpunit": "3.7.*",
    "phpunit/php-invoker": "1.1.3",
    "phpunit/dbunit": "1.2.3",
    "phpunit/phpunit-selenium": "1.3.2",
    "phpunit/phpunit-story": "1.0.2"
}
  1. Run hhvm composer.phar install --dev . 运行hhvm composer.phar install --dev If you did a composer system wide install, run hhvm /usr/local/bin/composer install --dev , it works too. 如果您进行了作曲家系统广泛安装,运行hhvm /usr/local/bin/composer install --dev ,它也可以。

  2. A vendor directory will be created. 将创建供应商目录。 The phpunit "binary" will be located at vendor/bin/phpunit phpunit“binary”将位于vendor/bin/phpunit

  3. To run PHPUnit for your project: hhvm vendor/bin/phpunit [optional arguments] 为您的项目运行PHPUnit: hhvm vendor/bin/phpunit [optional arguments]

Note: Probably in a not so distant future hhvm /usr/local/bin/phpunit [optional arguments] will work as expected, but right now this is the easiest option we have 注意:可能在不太遥远的未来hhvm /usr/local/bin/phpunit [optional arguments]将按预期工作,但现在这是我们最简单的选择

只需添加一个注释即可添加到@cabbey的asnwer:您可以使用-v选项设置IncludeSearchPaths值:

hhvm -v Server.IncludeSearchPaths.share=/usr/share/php/ $(which phpunit) MyTests.php

A simple workaround is to configure HHVM to include the PEAR libraries in it's search paths. 一个简单的解决方法是配置HHVM以在其搜索路径中包含PEAR库。

I added this to my config.hdf's Server section: 我把它添加到我的config.hdf的服务器部分:

    IncludeSearchPaths {
        forphpunit = /usr/lib/php/
    }

and then ran phpunit as: 然后运行phpunit:

hhvm -c ~/config.hdf /usr/bin/phpunit --bootstrap bootstrap.php MyTests.php

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM