Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
620 views
in Technique[技术] by (71.8m points)

ant - zend framework 2 + phpunit + multiple modules + continuous integration

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

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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>

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>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...