简单的PHP Selenium测试无法正常工作

3

我有以下的PHP Selenium测试:

<?php

require_once('PHPUnit/Extensions/SeleniumTestCase.php');

class Example extends PHPUnit_Extensions_SeleniumTestCase
{
  protected function setUp()
  {
    $this->setBrowser("*chrome");
    $this->setBrowserUrl("http://change-this-to-the-site-you-are-testing/");
  }

  public function testMyTestCase()
  {
    $this->open("/frontend_dev.php");
    try {
        $this->assertTrue($this->isTextPresent("Local Coupons"));
    } catch (PHPUnit_Framework_AssertionFailedError $e) {
        array_push($this->verificationErrors, $e->toString());
    }
  }
}

当我尝试运行它(通过运行“php filename.php”)时,出现错误:
PHP Fatal error:  Class 'PHPUnit_Framework_TestCase' not found in /usr/share/php/PHPUnit/Extensions/SeleniumTestCase.php on line 60

这很有道理,因为这个类在任何地方都没有定义,但是为什么呢?我安装了PHPUnit。一个名为PHPUnit_Framework_TestCase的类不会随PHPUnit一起被包含似乎有点奇怪。有什么想法吗?

1个回答

3

如果你需要使用命令行测试运行器,建议阅读PHPUnit文档(传送门)。你也可以在命令行中直接运行'phpunit --help'来查看帮助信息。我认为你会发现你需要像下面这样运行:

phpunit path/to/filename.php

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接