gpt4 book ai didi

php - 如何配置 Jenkins 作业以运行单元测试

转载 作者:可可西里 更新时间:2023-10-31 23:48:52 24 4
gpt4 key购买 nike

在 Jenkins 中为基于 Kohana 的项目创建作业后,我不知道如何配置该作业以运行单元测试。基本上我使用了 http://jenkins-php.org/ 中的模板,但 Kohana 有其独特的设置,不允许我像普通的 php 项目一样运行单元测试。由于 phpunit 命令不是从 CLI 运行的,所以我不断收到错误:

 [exec] ErrorException [ 1 ]: Call to undefined method Log::instance() ~ SYSPATH/classes/kohana/core.php [ 336 ]
[exec] PHP Notice: Undefined index: REMOTE_ADDR in /var/lib/jenkins/jobs/Construct-A-Cost Deployment Build/workspace/application/bootstrap.php on line 70
[exec] PHP Fatal error: Call to undefined method Log::instance() in /var/lib/jenkins/jobs/Construct-A-Cost Deployment Build/workspace/system/classes/kohana/core.php on line 336

在 build.xml 中,我有

 <target name="phpunit" description="Run unit tests with PHPUnit">
<mkdir dir="${basedir}/application/cache" />
<mkdir dir="${basedir}/application/logs" />
<exec dir="${basedir}/application/tests" executable="phpunit" failonerror="true" />
</target>

在application/tests/phpunit.xml中,我得到了

<phpunit colors="true" bootstrap="../../modules/unittest/bootstrap.php">
<testsuites>
<testsuite name="Calculation Tests">
<file>./classes/controller/calculation.php</file>
</testsuite>
</testsuites>
</phpunit>

任何人都可以分享您在 Jenkins 中设置 Kohana 工作的经验吗?谢谢!

更新:从 CLI 运行相同的测试,它在带有 PHPUnit 3.6.11 的 Windows XP 中工作,但在带有 PHPUnit 3.7.18 的 Ubuntu Server 中不起作用

最佳答案

我通过这两个步骤解决了这个问题:

sudo pear update-channels
sudo pear upgrade-all

它更新所有包,包括 PHPUnit。

关于php - 如何配置 Jenkins 作业以运行单元测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15943714/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com