Selenium RC - 无法重新声明 PHPUnit_Framework_TestCase 类
我在网上很多地方都找到了这个问题,但没有实际的解决方案。运行测试的默认代码是
<?php
set_include_path(get_include_path() . PATH_SEPARATOR . './PEAR/');
require_once 'Testing/Selenium.php';
require_once 'PHPUnit/Framework/TestCase.php';
class GoogleTest extends PHPUnit_Framework_TestCase
{
private $selenium;
public function setUp()
{
$this->selenium = new Testing_Selenium("*firefox",
"http://www.google.com");
$this->selenium->start();
}
public function tearDown()
{
$this->selenium->stop();
}
public function testGoogle()
{
$this->selenium->open("/");
$this->selenium->type("q", "hello world");
$this->selenium->click("btnG");
$this->selenium->waitForPageToLoad(10000);
$this->assertRegExp("/Google Search/", $this->selenium->getTitle());
}
}
?>
这给了我以下错误
Fatal error: Cannot redeclare class PHPUnit_Framework_TestCase in /usr/lib/php/PHPUnit/Framework/TestCase.php on line 115
我的包含路径看起来像这样
.:/usr/lib/php/ZendLatest/library/:/usr/lib/php/:./PEAR/
任何人都可以帮我解决这个问题吗?重新声明该类的位置并不明显,是在上述文件的第 115 行还是其他地方?
谢谢
This I have found on the net in various places but with no actual solution. The default code for running a test is
<?php
set_include_path(get_include_path() . PATH_SEPARATOR . './PEAR/');
require_once 'Testing/Selenium.php';
require_once 'PHPUnit/Framework/TestCase.php';
class GoogleTest extends PHPUnit_Framework_TestCase
{
private $selenium;
public function setUp()
{
$this->selenium = new Testing_Selenium("*firefox",
"http://www.google.com");
$this->selenium->start();
}
public function tearDown()
{
$this->selenium->stop();
}
public function testGoogle()
{
$this->selenium->open("/");
$this->selenium->type("q", "hello world");
$this->selenium->click("btnG");
$this->selenium->waitForPageToLoad(10000);
$this->assertRegExp("/Google Search/", $this->selenium->getTitle());
}
}
?>
This gives me the following error
Fatal error: Cannot redeclare class PHPUnit_Framework_TestCase in /usr/lib/php/PHPUnit/Framework/TestCase.php on line 115
My include path looks like this
.:/usr/lib/php/ZendLatest/library/:/usr/lib/php/:./PEAR/
Can anyone help me fix this? It isn't obvious where the class is being re-declared, is it on line 115 of the file mentioned above or somewhere else?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我通过将行更改
为
The
Framework.php
file is the Bootstrap for PHPUnit 并包含此处理所有其他包含内容来解决此问题。包含TestCase.php
不起作用,因为它不是 Bootstrap 文件,因此无法正确加载 PHPUnit。I have solved this by changing the line
To
The
Framework.php
file is the Bootstrap for PHPUnit and including this deals with all other includes. IncludingTestCase.php
doesn't work because that isn't the Bootstrap file and thus doesn't load PHPUnit correctly.