编程语言
首页 > 编程语言> > Phing看不到PHPUnit

Phing看不到PHPUnit

作者:互联网

我正在尝试设置一个新的Continuous Integration服务器,该服务器利用Phing和PHPUnit自动运行测试用例.

我已经在Pear中安装了Phing:

pear channel-discover pear.phing.info
pear install phing/phing

我已经使用新的PHAR方法安装了PHPUnit:

wget https://phar.phpunit.de/phpunit.phar
chmod +x phpunit.phar
mv phpunit.phar /usr/local/bin/phpunit

然后,我进入build.xml文件所在的目录,梯级phing,看来Phing不知道PHPUnit在哪里.

[jenkins@leroy workspace]$phing
Buildfile: /home/jenkins/.jenkins/jobs/Framework/workspace/build.xml

Framework > test:

 [echo] Running Tests
Execution of target "test" failed for the following reason: /home/jenkins/.jenkins/jobs/Framework/workspace/build.xml:9:37: /home/jenkins/.jenkins/jobs/Framework/workspace/build.xml:9:37: PHPUnitTask requires PHPUnit to be installed

BUILD FAILED
/home/jenkins/.jenkins/jobs/Framework/workspace/build.xml:9:37:
/home/jenkins/.jenkins/jobs/Framework/workspace/build.xml:9:37: PHPUnitTask requires PHPUnit to be installed
Total time: 0.0764 seconds

[jenkins@leroy workspace]$

检查了Phing和PHPUnit的位置:

[jenkins@leroy workspace]$which phing
/usr/bin/phing
[jenkins@leroy workspace]$which phpunit
/usr/local/bin/phpunit

并且,确保PHP是足够新的:

[jenkins@leroy workspace]$php -v
PHP 5.3.3 (cli) (built: Dec 11 2013 03:29:57) 

我之所以这样做,是因为我们要用新服务器替换旧的Jenkins服务器.尝试使用最新的软件,但我不知道如何告诉Phing在哪里可以找到PHPUnit.

在此先感谢您的帮助!

大卫

解决方法:

好像将pharlocation属性添加到phpunit task元素,指向本地phpunit可执行文件,就可以完成此工作:

<phpunit haltonfailure="true" haltonerror="true" 
    bootstrap="./fw_init.php" 
    pharlocation="/usr/local/bin/phpunit">
        <formatter type="plain" usefile="false" />
        ...
</phpunit>

标签:phing,php,jenkins,phpunit
来源: https://codeday.me/bug/20191012/1900108.html