3
,并在达到超时值,测试不停止或抛一个例外。相反,它只是继续前进,就像页面已成功加载一样。它执行点击并在第一个返回false的断言处停止。Selenium测试超时不停止测试的PHPUnit 3.6.10硒RC 2.19.0
我发现这个PHPUnit中3.6.10的提交日志:https://github.com/sebastianbergmann/phpunit/commit/cb772b06e9bd97f478fff7a212e3a4f7fe96bc29
例外看起来应该还是被抓,但不幸的是例外而不是好像不引发测试停止,所以我在这里失去了做什么。
下面是一个例子测试惹我谈论的行为:
<?php
class Example extends PHPUnit_Extensions_SeleniumTestCase
{
protected function setUp() {
$this->setBrowser('*firefox');
$this->setBrowserUrl('http://myserver/timeout.php');
$this->setTimeout(10);
$this->setWaitForPageToLoad(true);
}
public function testMyTestCase() {
// This should trigger an exception after timeout:
$this->openAndWait('/');
// Anything below this line SHOULD never be executed because of timeout:
$this->click('id=clicketyclickthiswontbeclicked');
$this->click('id=moreclicksthatwillnotbeclicked');
// This will fail the test, because timeout didn't stop it
$this->assertTextPresent('this text');
}
}
?>
下面的PHP文件应该触发超时。
timeout.php:
<?php
// Should trigger timeout
sleep(30);
// (...) Rest of the page
?>
我做得不对或可这是一个错误?