【问题标题】:command not found error while running php test code in command prompt在命令提示符下运行 php 测试代码时找不到命令错误
【发布时间】:2012-10-27 11:23:21
【问题描述】:

我关注了站点http://elentok.blogspot.com/2011/10/install-phpunit-on-wampserver.html 安装PHPUnit 框架以在PHP 中进行单元测试。我已经下载了 pear 和 PHPUnit。我已经按照上述网站中描述的步骤安装了它们。这也奏效了。但最后,我尝试运行 php 程序:::

class MyTest extends PHPUnit_Framework_TestCase
{
    public function testOneEqualsOne()
    {
      $this->assertEquals(1, 1);
    }
}

-> 我在命令提示符下键入了命令 phpunit Mytest.php,但没有运行。并显示错误phpunit is not识别为内部或外部命令,可运行程序或批处理文件。我已经在 c:\wampp\www\myproject> 上试过了。如何运行此代码并正确使用 PHPUnit 测试框架?安装有什么问题吗?我已经在 wampp 服务器上安装了 PHPUnit。如果我错了,请帮助我安装 PHPUnit 并正确使用它。我的系统是 Windows 07 64 位,我正在使用 wampp 服务器。

【问题讨论】:

  • 您是否以任何方式将 PHPUnit 类包含到您的 Mytest.php 中?
  • 不,我没有包括在内,怎么做?我们可以通过在我的代码 MyTest.php 顶部简单地编写 (include 'phpunit classname'; ) 命令来包含它吗?

标签: php tdd phpunit pear


【解决方案1】:

你必须在你的 php 测试文件中包含 Autoload.php 文件:

require_once 'path/to/PHPUnit/Autoload.php';

【讨论】:

    猜你喜欢
    • 2019-11-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-06-21
    • 1970-01-01
    • 2019-05-28
    • 2019-01-02
    相关资源
    最近更新 更多