1
votes

I found solution nowhere, there is différent way to do that but i just want to know if i can do this on this way :

Project
| - config
| - data
| - module
| | - Application
| | | - config
| | | - src
| | | - test <---------------------unit test for each module
| | | | - 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
| - tests <------------------centralize launch of all tests for reporting on Jenkins
| build.xml <----------------This file launch phpunit.xml in ./tests/phpunit.xml

On the root's tests directory i want to put an xml for launch every units test of every module and make a report file for Jenkins. I looked a lot of tutorial including :

centralize phpunit test

or question in stackoverflow wich is intersting but not what i want:

zf2 + phpunit + multiple module + CI

on stack, there is this question but i tried and it wasn't working :

Zend Framework 2 Unit Tests on Jenkins not working

thanks for helping

Edit[03/24/2014 - 12:25] : I have finally found a way to do that, it's to put Bootstrap.php, TestConfig.php on the tests directory.

Project
| - config
| - data
| - module
| | - moduleName1
| | | - config
| | | - src
| | | - test <---------------------unit test for each module
| | | | - ApplicationTest
| | | - view
| | | - Module.php
| | - moduleName2
| | | - config
| | | - src
| | | - test
| | | | - moduleName2Test
| | | - view
| | | - Module.php
| - public
| - vendor
| - tests
| | -phpunit.xml <-------- Jenkins fail here
| | -Bootstrap.php
| | -TestConfig.php
| build.xml <----------------This file launch phpunit.xml in ./tests/phpunit.xml

And my code for phpunit.xml is as follow :

<phpunit bootstrap="Bootstrap.php" colors="true"
    stopOnError="true"
    stopOnFailure="false"
    strict="true"
    verbose="true">
<testsuites>
    <testsuite name="All">
        <directory>../module/moduleName1/test/moduleName1Test</directory>
        <directory>../module/moduleName2/test/moduleName2Test</directory>
    </testsuite>
</testsuites>
<logging>
  <log type="coverage-html" target="../build/coverage/" charset="UTF-8"
       yui="true" highlight="false"
       lowUpperBound="35" highLowerBound="70"/>
  <log type="coverage-clover" target="../build/logs/clover.xml"/>
  <log type="junit" target="../build/logs/junit.xml" logIncompleteSkipped="false"/>
</logging>
</phpunit>

And, in line command, reports file are correctly generated, and my assert are good, all works perfectly.

BUT, there is a small thing that make me crazy !!! i can't find out what command i have to write on build.xml for launch phpunit.xml using jenkins i tried so much thing and jenkins keep saying :

Total tests run: 0, Failures: 0, Errors: 0, Incomplete: 0, Skipped: 0, Time elapsed: 0.00100 s

I'm sure my phpunit.xml is loaded, but it's simply not working... any ideas ?

1

1 Answers

0
votes

Problem finally solved :

in build.xml put the entire path of your phpunit.xml:

<target name="phpunit" description="Launch unit testing">
    <echo msg="Start Unit testing" />
    <exec command="phpunit.bat --configuration=C:/wamp/www/myProject/tests/phpunit.xml" />
</target>

if not your can have :

[exec] Could not read "./tests/phpunit.xml".

And jenkins goes happy !

 [exec] [30;42m[2KOK (4 tests, 4 assertions)