[英]PHPUnit & Selenium
我有两个问题:
我的两个测试用例是:
class AdminUserViewReqTabOptions extends PHPUnit_Extensions_Selenium2TestCase{
public function setUp()
{
$this->setHost('localhost'); // Set the hostname for the connection to the Selenium server.
$this->setPort(4444); // set port # for connection to selenium server
$this->setBrowser('firefox'); // set the browser to be used
$this->setBrowserUrl(''http://www.example.com'); // set base URL for tests
}
public function testShowRequestsOnHold()
{
$this->url('index.php'); // Set the URL to test
// check for the existence of the string 'Show requests on hold'
$this->assertRegExp( '/Show requests on hold/i', $this->source() );
}
public function testShowOnlyPendingApprovals()
{
$this->url('index.php'); // Set the URL to test
// check for the existence of the string 'Show requests on hold'
$this->assertRegExp( '/Show only Pending Approvals/i', $this->source() );
}
}
class AdminUserViewReqTabOptions extends PHPUnit_Extensions_Selenium2TestCase{
public function setUp()
{
$this->setHost('localhost'); // Set the hostname for the connection to the Selenium server.
$this->setPort(4444); // set port # for connection to selenium server
$this->setBrowser('firefox'); // set the browser to be used
$this->setBrowserUrl('http://www.example.com'); // set base URL for tests
}
public function testDisplayServer()
$this->url('index.php'); // Set the URL to test
// check for the existence of the strin 'All Open'
$this->assertRegExp( '/Server: Development/i', $this->source() );
}
}
1)如果所有测试都位于同一目录中,请尝试使用目录名而不是文件名来调用phpunit。 phpunit将在给定目录中查找* Test.php。
2)从setUp()函数中删除setHost(),setPort()和setBrowser(),并以静态属性声明浏览器。 下面将在每个声明的浏览器中运行每个测试。
public static $browsers = [
[
'host' => 'localhost',
'port' => 4444,
'browserName' => 'firefox'
],
[
'host' => 'localhost',
'port' => 4444,
'browserName' => 'chrome'
]
];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.