代码覆盖与PHPUnitSeleniumTestcase
我已经为
PHP编写了Selenium Test案例.我想在执行这些测试用例时获取代码覆盖.我的测试用例:
<?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"); } } ?> 我已经遵循链接“http://www.phpunit.de/manual/current/en/selenium.html”中提到的步骤 运行测试后,我无法找到代码覆盖.在phpunit_coverage.php中,它的名字是PHPUNIT_SELENIUM_TEST_ID.这个cookie是在Driver.php中创建的,我看到cookie是可用的,但是它的主机名设置为“localhost”,而不是我的应用程序名称. Cookie生命周期设置为会话,即在测试用例执行后立即表示此cookie将不再可用,并且当我尝试启动phpunit_coverage.php时,它无法找到cookie和信息,因此不会显示代码覆盖. 我不明白的事情 > protected $coverageScriptUrl =’http://applicationname/phpunit_coverage.php’; 我已经看到这个问题在许多论坛上被讨论,但有一个具体答案 许多论坛建议使用localhost而不是127.0.0.1作为服务器名称.在我的情况下,它已经是localhost. 在这方面的任何建议将是有帮助的. 谢谢,
与Selenium的集成或功能测试不包括代码,因为它们覆盖了行为.针对这样的测试的代码覆盖率报告不会产生任何有用的信息.单元测试将产生更有意义的代码覆盖率报告.这些测试是根据Selenium提供的信息来运行的,但实际上并没有真正测试您的“代码”.
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |