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
?>
我做得不對或可這是一個錯誤?