私の一般的なテスト設定は次のようになります。
class MySeleniumTest extends PHPUnit_Extensions_SeleniumTestCase{
public static $browsers = array(
array(
'name' => 'Mozilla - Firefox',
'browser' => '*firefox',
'host' => 'localhost',
'port' => 4444,
'timeout' => 30000,
),
array(
'name' => 'Google - Chrome',
'browser' => '*googlechrome',
'host' => 'localhost',
'port' => 4444,
'timeout' => 30000,
)
);
//etc
}
ここから、個々のテスト ファイルは次のようになります。
class MyTest extends MySeleniumTest{
public function setUp(){
parent::setUp();
$this->setUser(1);
}
public function testPageTitle(){
//Login and open the test page.
$this->login(8);
$this->open('/test/page');
//Check the title.
$this->assertTitle('Test Page');
}
}
ここから、PHPUnit で実行するMyTest.php
と、PHPUnit は自動的に各テスト ケースを で実行しMyTest.php
ます。さらに、指定された各ブラウザーで個別に各テストを実行します。私ができるようにしたいのは、そのテスト ケース内から特定のテスト ケースを実行しているドライバーに関する情報を取得することです。次のようなものです:
public function testPageTitle(){
//Login and open the test page.
$this->login(8);
$this->open('/test/page');
//Check the title.
$this->assertTitle('Test Page');
$driver = $this->getDriver();
print($driver['browser']); //or something.
}
ただし、これは機能しません。そして$this->getDrivers()
、テストにドライバーを追加するだけで、セットアップでのみ使用されると想定されています。何か案は?ありがとう!