问题描述
预先感谢您的任何评论.我刚刚开始从 Zend Framework 1 切换到 ZF2,在完成快速入门和其他几个教程后,我注意到使用 phpunit 的默认"方式有一个短板.要么是那样,要么我只是迷失了方向.
Thanks in advance for any comments. I have just started to switch from Zend Framework 1 to ZF2 and after running through the quick start and several other tutorials I noticed that there is a short coming with the 'default' way to use phpunit. Either that or I am just lost and confused.
默认项目的文件夹结构是
The folder structure for a default project is
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.
My question is this how do I use Jenkins with ANT to test all of the phpunit test suites. I understand the reason behind testing each module individually but how can I properly automate that to get one report.xml back. And it would be even better if I didn't need to specify each module in a phpunit config. or the build.xml.
再次感谢您的任何评论.
Again thank you for any comments.
推荐答案
当我发现问题时忘记回答我自己的问题 我向我忘记的社区道歉......但为了大家的利益,我是如何得到它的工作.
I forgot to answer my own question when I figured it out I apologize to the community that I forgot... but for everyones benefit here is how I got it to work.
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
And the phpunit.xml for each module
<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>
这篇关于zend 框架 2 + phpunit + 多个模块 + 持续集成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!