duanlu4371 2011-01-12 15:58
浏览 68
已采纳

Selenium RC - 无法重新声明类PHPUnit_Framework_TestCase

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

  • 写回答

1条回答 默认 最新

  • douao1959 2011-01-13 10:45
    关注

    I have solved this by changing the line

     require_once 'PHPUnit/Framework/TestCase.php';
    

    To

    require_once 'PHPUnit/Framework.php';
    

    The Framework.php file is the Bootstrap for PHPUnit and including this deals with all other includes. Including TestCase.php doesn't work because that isn't the Bootstrap file and thus doesn't load PHPUnit correctly.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥50 关于#html5#的问题:H5页面用户手机返回的时候跳转到指定页面例如(语言-javascript)
  • ¥15 无法使用此凭据登录,因为你的域不可用,如何解决?(标签-Windows)
  • ¥15 yolov9的训练时间
  • ¥15 二叉树遍历没有报错但无法正常运行
  • ¥15 在linux系统下vscode运行robocup3d上场球员报错
  • ¥15 Python语言实验
  • ¥15 SAP HANA SQL 增加合计行
  • ¥20 用C#语言解决一个英文打字练习器,有偿
  • ¥15 srs-sip外部服务 webrtc支持H265格式
  • ¥15 在使用abaqus软件中,继承到assembly里的surfaces怎么使用python批量调动