PHP用のSeleniumテストケースを作成しました。私はこれらのテストケースを実行している間、コードカバレッジを取得したいと思います。私のテストケース:私は私がテストを実行した後、リンク「http://www.phpunit.de/manual/current/en/selenium.html」PHPUnitSeleniumTestcaseのコードカバレッジ
で述べた手順に従っている
<?php
class Example extends PHPUnit_Extensions_SeleniumTestCase
{
protected $coverageScriptUrl = 'http://applicationname/phpunit_coverage.php';
protected function setUp()
{
$this->setBrowser("*firefox");
$this->setBrowserUrl("http://applicationname");
$this->setCollectCodeCoverageInformation(true);
$this->setTestId("10001");
$this->setHost("applicationname");
}
public function testMyTestCase()
{
$this->open("http://applicationame");
$this->assertEquals("title", $this->getTitle());
$this->type("id=ext-comp-1002", "testuser");
$this->fireEvent("id=ext-comp-1002", "blur");
$this->type("id=ext-comp-1003", "testpassword");
$this->fireEvent("id=ext-comp-1003", "blur");
$this->click("ext-gen45");
$this->waitForPageToLoad("200000");
}
}
?>
コードカバレッジを見つけることができません。 phpunit_coverage.phpでは、名前がPHPUNIT_SELENIUM_TEST_IDのクッキーを探しています。このCookieはDriver.phpで作成されており、Cookieが利用可能ですが、ホスト名はアプリケーション名ではなく「localhost」に設定されています。
クッキーライフタイムが設定されているのは、テストケースの実行直後です。つまり、このクッキーはもう使用できなくなり、phpunit_coverage.phpを起動しようとするとクッキーと情報が見つからないため、コードカバレッジは表示されません。私は理解していない
もの:
protected $coverageScriptUrl = 'http://applicationname/phpunit_coverage.php';
- クッキーは私が議論されているこの問題を見てきました。このクッキーは、アクセス可能な
ことができるアプリケーション以外の別のホストを持っていた場合多くのフォーラムがありましたが、具体的な回答がありました
多くのフォーラムでの代わりにlocalhost
サーバー名として。私の場合は、すでにlocalhostです。
この点に関するご意見はお役に立ちます。彼らは行動をカバーしているよう
おかげで、セレンと Ravuri
多分この質問に対する回答が役立つかもしれません:http://stackoverflow.com/questions/11270527/does-phpunit-selenium-code-coverage-work – Potherca