测试不工作但没有错误PHPUnit不会';找不到文件


Test not working but no errors PHPUnit doesn't find file?

首次使用PHPUnit和Selenium。为Firefox安装了SeleniumIDE插件,并使用记录器创建了一些简单的测试。IDE默认情况下将测试格式化为HTML表,因此我将PHP格式化程序插件安装到Selenium插件中,并能够将测试导出为PHPUnit格式。接下来在Windows7上安装了PHPUnit。还为PHPUnit安装了Selenium插件。

然后使用以下命令运行我的测试:

phpunit Mytests.php

输出为:

Time: 0 seconds, Memory: 2.7Mb
OK (0 tests, 0 assertions)

很好,没有错误,但看起来测试也没有运行。怎么了?是我的测试文件的内容吗:

<?php
require_once 'PEAR/PHPUnit/Extensions/SeleniumTestCase.php';
class Mytests extends PHPUnit_Extensions_SeleniumTestCase
{
  protected function setUp()
  {
    $this->setBrowser("*chrome");
    $this->setBrowserUrl("http://www.foobar.com/");
  }
  public function related_videos()
  {
    // // make sure there are 4 related items
    $this->open("/");
    $this->click("xpath=//div[contains(@id, 'featured')]/article/div/a[contains(@class,'thumb')]");
    $this->waitForPageToLoad("30000");
    try {
        $this->assertEquals("4", $this->getXpathCount("//descendant-or-self::*[@id = 'related']/descendant::article"));
    } catch (PHPUnit_Framework_AssertionFailedError $e) {
        array_push($this->verificationErrors, $e->toString());
    }
  }
}
?>

Phpunit正在测试用例实例上寻找以"test"开头的方法名称,如果您将related_videos方法重命名为test_related_videos,它应该找到并运行它。