小编典典

zend framework 2 + phpunit +多个模块+持续集成

jenkins

预先感谢您的任何评论。我刚刚开始从Zend Framework
1切换到ZF2,并且在完成了快速入门和其他一些教程之后,我注意到使用phpunit的“默认”方式有一个缺点。要么,要么我迷路了。

默认项目的文件夹结构为

Project
| - config
| | - autoload
| | | - global.php
| | | - local.php.dist
| | - application.config.php
| - data
| - module
| | - Application
| | | - config
| | | - src
| | | - test
| | | | - ApplicationTest
| | | | - Bootstrap.php
| | | | - phpunit.xml
| | | | - TestConfig.php.dist 
| | | - view
| | | - Module.php
| | - Album
| | | - config
| | | - src
| | | - test
| | | | - AlbumTest
| | | | - Bootstrap.php
| | | | - phpunit.xml
| | | | - TestConfig.php.dist 
| | | - view
| | | - Module.php
| - public
| - vendor

我的问题是,我如何将Jenkins与ANT一起使用,以测试所有phpunit测试套件。我了解分别测试每个模块背后的原因,但是如何正确地自动化它以获取一个report.xml。如果我不需要在phpunit配置中指定每个模块,那就更好了。或build.xml。

再次感谢您的任何评论。


阅读 260

收藏
2020-07-25

共1个答案

小编典典

当我发现这个问题时,我忘了回答自己的问题,我向忘了的社区表示歉意……但是,对于每个人来说,这是如何使它起作用的。

build.xml

<target name="phpunit" description="Run unit tests with PHPUnit">
    <apply executable="../vendor/bin/phpunit" parallel="false">
        <fileset dir="${env.WORKSPACE}/module" >
            <include name="**/test/phpunit.xml"/>
        </fileset>
        <arg value="--configuration" />
        <srcfile/>
    </apply>
</target>

以及每个模块的phpunit.xml

<phpunit bootstrap="Bootstrap.php">
    <testsuites>
        <testsuite name="Application">
            <directory>./</directory>
        </testsuite>
    </testsuites>

<!-- Filters only matter for code coverage reporting -->
    <filter>
        <blacklist>
            <directory>../../../vendor/</directory>
            <directory>./</directory>
            <file>../Module.php</file>
        </blacklist>
    </filter>
    <logging>
        <log type="coverage-html" target="../../../build/coverage" title="Application Module" charset="UTF-8" yui="true" highlight="true" lowUpperBound="35" highLowerBound="70"/>
        <log type="coverage-clover" target="../../../build/logs/clover-Application.xml"/>
        <log type="junit" target="../../../build/logs/junit-Application.xml" logIncompleteSkipped="false"/>
    </logging>
</phpunit>
2020-07-25