dongpu6141 2017-08-14 21:12
浏览 90
已采纳

PHPUnit在空缓存上运行超时

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.

  • 写回答

2条回答 默认 最新

  • dongru2019 2017-08-16 13:56
    关注

    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> 
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?