Unit testing Selenium/PHPUnit测试始终运行两次,第二次通过时失败

Unit testing Selenium/PHPUnit测试始终运行两次,第二次通过时失败,unit-testing,selenium,phpunit,Unit Testing,Selenium,Phpunit,我遇到的问题是,我为Selenium/PHPUnit测试设置了运行程序,每次测试都会运行两次,一次又一次。然后它将进入下一个测试。我发现这个bug似乎正是发生在我身上的事情——所以我删除了对PHPUnit_MAIN_方法的所有引用,但我仍然有同样的问题,而且似乎“bug”在两年前就已经解决了,我正在使用PHPUnit的最新版本 以下是我的跑步者代码: <?php require_once '/libs/prefix.php'; class WWW_TestSuite { public s

我遇到的问题是,我为Selenium/PHPUnit测试设置了运行程序,每次测试都会运行两次,一次又一次。然后它将进入下一个测试。我发现这个bug似乎正是发生在我身上的事情——所以我删除了对PHPUnit_MAIN_方法的所有引用,但我仍然有同样的问题,而且似乎“bug”在两年前就已经解决了,我正在使用PHPUnit的最新版本

以下是我的跑步者代码:

<?php
require_once '/libs/prefix.php';

class WWW_TestSuite
{
public static function main()
{
    PHPUnit_TextUI_TestRunner::run(self::suite());
}

public static function suite(){
    global $TEST_CASES, $TEST_FILES, $DOMAINS, $SUB_DOMAINS, $LOG_FILES;
    $suite = new PHPUnit_Framework_TestSuite('PHPUnit Framework');
    $GLOBALS['testDomain'] = 'cco';
    $GLOBALS['startURL'] = 'www.domain.com';
    $GLOBALS['resultsFile'] = $LOG_FILES['www.domain.com'];
    $numberOfTests = count($TEST_CASES['cco']);
    $resultsFile = $GLOBALS['resultsFile'];
    $fh = fopen($resultsFile, 'w');
    fwrite($fh, CRLF.DELIM_PLUS.CRLF);
    fwrite($fh, $numberOfTests.NUMBER_OF_TESTS_STRING.CRLF);
    fwrite($fh, DELIM_PLUS.CRLF);
    fclose($fh);
    foreach ($TEST_CASES['cco'] as $testCase){
        include $TEST_FILES['cco'][$testCase];
        $suite->addTestSuite($testCase);
    }
    return $suite;
}
}
?>
结果文件只会更新第一次测试的结果(这是正常行为,如果我们在测试中得到一个E,我们就不会得到日志记录,但我想知道为什么它一开始会运行两次

编辑: 忘记包含我的安装文件:

<?php
global  $TEST_NAME_URL_RELATION;
$testName = get_class($this);       
$this->reporting = new reporting();
$this->errorLines = array();
$this->startURL = $GLOBALS['startURL'];
$this->setBrowser("*firefox");
$this->setBrowserUrl("http://".$this->startURL);
$this->testUrlRoot = $TEST_NAME_URL_RELATION[$GLOBALS['testDomain']][$testName];
$this->testURL = $this->startURL.$this->testUrlRoot;
print ($this->testURL."\n");
?>

该函数

public function testContentPresent
在我的报告类中,这是问题的根源——Selenium自动运行任何以单词“test”开头的方法,因此每次实际测试都会运行两次

更名为:

public function ContentPresent
现在它可以工作了。

函数

public function testContentPresent
在我的报告类中,这是问题的根源——Selenium自动运行任何以单词“test”开头的方法,因此每次实际测试都会运行两次

更名为:

public function ContentPresent

现在它可以工作了。

好的发现。你有没有可能将链接添加到有此参考的Selenium文档?肯定是指向书签的好链接好的发现。你有没有可能将链接添加到有此参考的Selenium文档?肯定是指向书签的好链接
public function ContentPresent