运行所有zend framework2单元测试

vei*_*lig 6 phpunit unit-testing jenkins zend-framework2

我正在尝试在Jenkins for Zend Framework 2中获得项目构建设置,我想为我正在编写的每个模块运行所有单元测试 - 但我不清楚如何做到这一点?

每个模块都有自己的'test'目录,我可以运行每个模块测试套件.我是否必须编写一些脚本来查找所有自定义模块并运行其测试?有没有人有一个很好的例子如何做到这一点?

Ain*_*ine 2

首先,让测试一起运行

我会尝试编写一个新的 phpunit 配置文件,例如 all.xml,给出不同测试文件的详细信息。

 <phpunit>
     <testsuite name="Module1">
          <directory>./module1</directory>
     </testsuite>
    <testsuite name="Module2">
          <directory>./module2</directory>
     </testsuite>
     <testsuite name="Module2">
          <directory>./module3</directory>
     </testsuite>
</phpunit>
Run Code Online (Sandbox Code Playgroud)

测试这在命令行上运行正常

$ phpunit -c all.xml
Run Code Online (Sandbox Code Playgroud)

添加到詹金斯

只需将其添加到 Jenkins 配置中即可。以下是使用 Ant xml 文件的示例:

<target name="phpunit" description="Run unit tests with PHPUnit">
    <exec executable="phpunit" failonerror="true">
        <arg line=" -c tests/all.xml" />
    </exec>
</target>
Run Code Online (Sandbox Code Playgroud)