【问题标题】:How to use zend test phpunit in zend project如何在zend项目中使用zend test phpunit
【发布时间】:2011-04-14 08:24:07
【问题描述】:

我是一个非常新的 zend 框架和 phpunit 测试学习者。 我有一个zend项目,我想使用zend-test-phpunit来测试应用程序文件夹下的模型和控制器。我怎么能测试它?我注意到这个项目中有一个测试文件夹,所有的测试都应该在这个文件夹中完成?在这种情况下,我必须将所有控制器和模型复制到此文件夹中吗?谁能给我一个例子?

提前感谢您的帮助!

【问题讨论】:

    标签: zend-test


    【解决方案1】:

    一个好的起点是Zend Framework documentation 和 PHPUnit 手册:Chapter 3. Installing PHPUnit

    您需要使用以下内容填充phpunit.xml 文件:

    <phpunit bootstrap="./application/bootstrap.php" colors="true">
            <testsuite name="Application" >
                    <directory>./library</directory>
                    <directory>./application</directory>
            </testsuite>
            <filter>
                    <whitelist>
                            <directory suffix=".php">../application</directory>
                            <directory suffix=".php">../library/My</directory>
                            <exclude>
                                    <directory suffix=".phtml">../application/</directory>
                                    <file>../application/Bootstrap.php</file>
                            </exclude>
                    </whitelist>
            </filter>
        <logging>
            <log type="coverage-html" target="./log/report" charset="UTF-8"
            yui="true" highlight = "true" lowUpperBound="50" highLowerBound="80" />
            <log type="testdox" target="./log/testdox.html" />
        </logging>
    </phpunit>
    

    然后它只是在你的测试文件夹中从命令行运行'phpunit'。如果你想让 phpunit 生成代码覆盖率报告,那么你还需要在你的环境中启用 xdebug

    【讨论】:

      猜你喜欢
      • 2012-08-16
      • 2014-08-10
      • 2014-04-27
      • 2016-05-11
      • 2015-06-21
      • 2014-02-10
      • 2010-10-11
      • 1970-01-01
      • 2012-03-04
      相关资源
      最近更新 更多