douxi9245 2012-07-20 17:57
浏览 54
已采纳

为什么我的PHPUnit测试不起作用?

First time using PHPUnit and Selenium. Installed Selenium IDE plugin for Firefox, created some simple tests using the recorder. The IDE formats the tests as HTML tables by default so I installed the PHP formatter addon to the Selenium addon and was able to export the tests as PHPUnit format. Next installed PHPUnit on Windows 7. Also installed the Selenium plugin for PHPUnit.

Then ran my tests using this command:

phpunit Mytests.php

output is:

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

So great no errors, but it doesn't look like the tests have run either. What's wrong? Is it the contents of my test file:

<?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());
    }
  }

}
?>
  • 写回答

1条回答 默认 最新

  • dosi8657 2012-07-20 18:04
    关注

    Phpunit is looking for method names starting with "test" on the testcase instances, if you rename the related_videos method to test_related_videos it should find and run it.

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

报告相同问题?

悬赏问题

  • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?
  • ¥15 乘性高斯噪声在深度学习网络中的应用
  • ¥15 运筹学排序问题中的在线排序
  • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
  • ¥30 求一段fortran代码用IVF编译运行的结果
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛