PHPUnit在空缓存上运行超时

问题描述 投票:0回答:2

我正在尝试使用phing创建构建过程。在这个过程中,我想运行作曲家安装脚本和phpunit,它由作曲家安装

在我的构建文件中,我有2个目标。

<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>

composer.phar和phpunit.xml在我的项目基础中。现在,如果我运行phpunit目标,我可以看到在需要时检查和安装依赖项。但PHPUnit只返回

Sebastian Bergmann和贡献者的PHPUnit 5.7.21。

就是这样。实际上没有测试。似乎永远不会读取配置文件。

如果我从phpunit目标中删除依赖项然后运行,则实际完成测试并创建日志和覆盖率报告。我正在使用exec而不是phpunit任务,因为phings代码覆盖似乎在命名空间中的反斜杠有问题。

这实际上是一个Symfony项目和调用

bin/console cache:warmup -e test

解决了这个问题

虽然在composer安装之后从命令行调用PHPUnit实际上运行了测试。

在phing或PHPUnit中我可以在哪里更改超时吗? php的最大执行时间设置为0。

php symfony phpunit composer-php phing
2个回答
1
投票

如何调整build.xml来创建一个预热缓存的任务:

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

然后让phpunit任务也依赖于该任务:

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

0
投票

从Phing 3.x开始,你也可以使用SymfonyConsoleTask

<project name="symfony-cmd" default="phpunit" basedir=".">

    <target name="setup">

        <composer command="install" composer="./composer.phar" />

        <autoloader autoloaderpath="./vendor/autoload.php" />

        <symfonyconsole console="./bin/console" command="cache:warmup">
            <arg name="env" value="test" />
        </symfonyconsole>

    </target>

    <target name="phpunit" depends="setup">
        <!-- ... -->
    </target>

</project>
© www.soinside.com 2019 - 2024. All rights reserved.