【问题标题】:PHPUnit returns different results (for the same set of Zend Framework project files) on differnt locationPHPUnit 在不同的位置返回不同的结果(对于同一组 Zend Framework 项目文件)
【发布时间】:2011-12-26 14:57:13
【问题描述】:

我的 PHPUnit 测试环境设置为针对 ZF 项目运行。并且从一个地方运行得很好。但是当我将所有项目文件(通过 git clone)移动到另一个地方时,phpunit 运行,但返回“OK(0 个测试,0 个断言)”,虽然确实有几个测试。

相同的过程在 2 个不同的位置运行良好,直到我手动将 phpunit 从 3.6.5 降级到 3.4.15(这对于 ZF 项目来说似乎是不可避免的)。不知道出了什么问题?或者如果我可以检查来自 phpunit 的任何执行日志?

我的 phpunit.xml

<phpunit bootstrap="./application/bootstrap.php" colors="true">
  <testsuites>
    <testsuite name="myTests">
        <directory>./</directory>
    </testsuite>
  </testsuites>

    <filter>
        <whitelist>
            <directory suffix=".php">../application/</directory>
            <exclude>
                <directory suffix=".phtml">../application/</directory>
                <file>../application/Bootstrap.php</file>
                <file>../application/controllers/ErrorController.php</file>
            </exclude>
        </whitelist>
    </filter>

</phpunit>

出来了:

Sebastian Bergmann 的 PHPUnit 3.4.15。

时间:0 秒,内存:9.50Mb

OK(0 个测试,0 个断言)


扩展位置:

Sebastian Bergmann 的 PHPUnit 3.4.15。

.....

时间:0 秒,内存:30.75Mb

OK(5 个测试,11 个断言)

【问题讨论】:

    标签: php zend-framework phpunit


    【解决方案1】:

    您想降级到 3.5.15 而不是 3.4.15,并且只是为了更好地衡量将suffix="Test.php" 添加到您的目录标签。

    两者中的一个应该可以解决问题

    【讨论】:

    • 感谢您的回复,edorian。我最终将其缩小到目录路径中包含点 (.) 的问题。喜欢: /home/simon/git-clone 可以正常工作; /home/.simon/git-clone 不会。所以对我来说解决方案很简单,只需在路径中没有点的另一个位置启动服务器。我猜这是 phpunit 3.4.x 的一个已知问题。不过,这并没有发生在 3.6.3 上。顺便说一句,我试图将它从 pear 降级到 3.5.15,但总是得到最新的版本。这是关于此的帖子:dustyreagan.com/downgrade-phpunit-3-6-to-3-5-15 但我不确定 ZF 是否可以正常工作。仅供参考。
    • @simonxy 不错的链接!这肯定会派上用场:) - 如果您的问题得到解决,请单击我的答案旁边的复选标记,让人们知道他们不需要再次检查这个问题,因为它已经解决了。 (或者如果您想让其他人更容易找到您发现的内容,请编写您自己的答案并接受它作为解决方案:))
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-10-31
    • 2011-10-25
    相关资源
    最近更新 更多