phpsymfonyphpunitcomposer-phpphing

PHPUnit times out running on empty cache


I'm trying to create a build process using phing. During this process I want to run the composer install script and phpunit, which is installed by composer

Inside my buildfile I have 2 targets.

<target name="composer">
    <composer command="install" composer="./composer.phar" />
    <autoloader autoloaderpath="./vendor/autoload.php" />
</target>
<target name="phpunit" depends="composer">
    <if>
        <os family="windows" />
        <then>
            <property name="phpunit.executable" value="phpunit.bat" />
        </then>
        <else>
            <property name="phpunit.executable" value="phpunit" />
        </else>
    </if>
    <exec executable="vendor/bin/${phpunit.executable}"
      dir="${project.basedir}" level="debug"
      returnProperty="phpunit.return">
        <arg line="--configuration" />
        <arg file="${project.basedir}/phpunit.xml" />
    </exec>
</target>

The composer.phar and phpunit.xml are in my project base. Now if I run the phpunit target I can see that the dependencies are checked and installed if needed. But PHPUnit only returns

PHPUnit 5.7.21 by Sebastian Bergmann and contributors.

and that is it. No tests are actually run. It seems like the configuration file is never read.

If I remove the depends from the phpunit target and run then, the tests are actually completed and logs and coverage report created. I'm using exec instead of the phpunit task because phings code coverage seems to have trouble with the backslashes in namespaces.

This is actually a Symfony project and calling

bin/console cache:warmup -e test

fixes the problem

Though calling PHPUnit from command line after composer install does actually run the tests.

Is there anywhere in phing or PHPUnit where I can change that timeout? The max execution time for php is set to 0.


Solution

  • How about adjusting build.xml to create a task to warm up the cache:

    <target name="cache-warmup">
        <exec command="bin/console cache:warmup -e test" />
    </target> 
    

    and then have the phpunit task also depend on that task:

    <target name="phpunit" depends="composer cache-warmup">
        ...
    </target>