Zend Framework 2在Jenkins上的单元测试不起作用 [英] Zend Framework 2 Unit Tests on Jenkins not working

查看:105
本文介绍了Zend Framework 2在Jenkins上的单元测试不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个zend framework 2项目,我正在尝试设置我的詹金斯,以便可以执行单元测试. Jenkins在ubuntu上运行,我正在Windows 7下使用PHPStorm进行开发.

I have a zend framework 2 project and i am trying to set up my jenkins so that unit tests can be executed. Jenkins is running on ubuntu and i am developing under Windows 7 with PHPStorm.

build.xml

build.xml

<target name="phpunit" description="Run unit tests with PHPUnit">
    <exec executable="phpunit" failonerror="true">
        <arg value="${basedir}/module/Addressbook/test"/>
    </exec>
</target>

文件夹结构:

  • 项目
    • 模块
      • 通讯录
      • 测试
        • 地址簿测试
          • 控制器
            • AddressbookControllerTest.php
            • Folder structure:

              • project
                • module
                  • Addressbook
                  • test
                    • AddressbookTest
                      • Controller
                        • AddressbookControllerTest.php
                        • 
                          phpunit:
                               [exec] PHPUnit 3.7.13 by Sebastian Bergmann.
                               [exec] 
                               [exec] PHP Fatal error:  Class 'AddressbookTest\Bootstrap' not found in /var/lib/jenkins/workspace/Test/src/module/Addressbook/test/AddressbookTest/Controller/AddressbookControllerTest.php on line 28

                          我的本​​地计算机上的PHPStorm在运行phpunit.xml.dist时会执行此操作

                          PHPStorm on my local machine does this when running phpunit.xml.dist

                          
                          D:\Zend\ZendServer\bin\php.exe -d auto_prepend_file=D:/Zend/Apache2/htdocs/demoshop/vendor/autoload.php C:\Users\ChristianB\AppData\Local\Temp\ide-phpunit.php --configuration D:/Zend/Apache2/htdocs/demoshop/module/Addressbook/test/phpunit.xml.dist

                          我如何将其用于詹金斯?

                          How can i use that for jenkins?

                          推荐答案

                          似乎您的包含路径未正确设置,当有更好的选择时,我不会直接将exec与PHPUNIT一起使用.

                          It looks like your include path isn't setup correctly, I wouldn't use exec directly with PHPUNIT when there's better options.

                          您应该研究将PHING任务与Jenkins一起使用,它们可以很好地协同工作.

                          You should look into using PHING tasks with Jenkins, they work excellent together.

                          然后,您将Jenking设置为触发PHING目标,以通过PHPUNIT任务(PHPUNIT的示例phing目标)为您运行单元测试:

                          You then setup Jenking to trigger your PHING target to run the unit tests for you via the PHPUNIT task, an example phing target for PHPUNIT:

                          <target name="phpunit">
                              <phpunit bootstrap="${srcdir}/tests/bootstrap.php">
                                  <formatter todir="${builddir}/reports" type="xml"/>
                                  <batchtest>
                                      <fileset dir="${srcdir}/tests">
                                          <include name="**/*Test*.php"/>
                                          <exclude name="**/Abstract*.php"/>
                                          <exclude name="${srcdir}/vendor/**"/>
                                      </fileset>
                                  </batchtest>
                              </phpunit>
                              <!-- 
                                  Generate a report from the XML data created.. 
                                  note: error when using format="frames"
                              --> 
                              <phpunitreport infile="${builddir}/reports/testsuites.xml" 
                                  format="noframes" 
                                  todir="${builddir}/reports/tests"
                              />
                          
                          </target>
                          

                          这篇关于Zend Framework 2在Jenkins上的单元测试不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆