I have written Selenium Test case for PHP. I would like to get the code coverage for while I execute these test cases. My testcase:
<?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");
}
}
?>
I have followed the steps mentioned in the link "http://www.phpunit.de/manual/current/en/selenium.html"
After running the test I am not able to find the code coverage. In phpunit_coverage.php, it is looking cookie with name PHPUNIT_SELENIUM_TEST_ID. This cookie is being created in Driver.php and I see cookie is available, but it has hostname to set to "localhost" rather than my application name.
Cookie life time is set session i.e. means immediately after test case execution this cookie will no longer available and when I try to launch phpunit_coverage.php, it is not able to find the cookie and information so no code coverage is appearing.
Things I don't understand:
protected $coverageScriptUrl = 'http://applicationname/phpunit_coverage.php';
- If the cookie has has different host other than application can this cookie be accessable
I have seen this problem being discussed in many forums, but one gave concrete answer
Many forums suggested to use localhost
instead of 127.0.0.1
as server name. In my case it is already localhost.
Any suggestion in this regard will be helpful.
Thanks, Ravuri