In the PHPUnit docs,它说,它可能得到的代码覆盖率数据:PHPUnit_Selenium代码覆盖率是否工作?
复制的PHPUnit /扩展/ SeleniumTestCase/phpunit_coverage.php:
PHPUnit_Extensions_SeleniumTestCase的可以收集代码覆盖率信息通过测试运行硒进入您的网络服务器的文档根目录。
在你的web服务器的php.ini配置文件,配置的PHPUnit /扩展/ SeleniumTestCase/prepend.php和PHPUnit的/扩展/ SeleniumTestCase/append.php分别中的auto_prepend_file和auto_append_file所。
在你的测试用例类,它扩展了PHPUnit_Extensions_SeleniumTestCase,使用 保护$ coverageScriptUrl = 'HTTP://host/phpunit_coverage.php'; 配置phpunit_coverage.php脚本的URL。
我一直没能得到这个输出的任何覆盖信息。我可以通过正常的单元测试获得代码覆盖率信息。
对于在http://localhost/ts2_templates/
运行我的应用程序,我复制到phpunit_coverage.php
http://localhost/phpunit_coverage.php
。
我已经添加了以下为php.ini:
auto_prepend_file = "/path/to/pear/share/pear/PHPUnit/Extensions/SeleniumTestCase/prepend.php"
auto_append_file = "/path/to/pear/share/pear/PHPUnit/Extensions/SeleniumTestCase/append.php"
...并核实他们被称为用die("yep it's me");
。
最后,我增加了以下我的测试用例:
<?php
class WebTest extends PHPUnit_Extensions_Selenium2TestCase
{
# added line below
protected $coverageScriptUrl = 'http://localhost/phpunit_coverage.php';
protected function setUp()
{
$this->setBrowser('firefox');
$this->setBrowserUrl('http://localhost/ts2_templates');
}
public function testTitle()
{
$this->url('http://localhost/ts2_templates');
$this->assertContains('test', $this->title());
}
}
?>
下面是运行的代码覆盖测试命令,通过PHPStorm产生:
/Applications/MAMP/bin/php5.3/bin/php -dxdebug.coverage_enable=1 /private/var/folders/pp/0t4y41f95j5313qm_f8b42fw0000gn/T/ide-phpunit.php --coverage-clover /path/to/coverage/ts2_templates$WebTest.coverage --no-configuration WebTest /Users/Ian/php/ts2_templates/tests/WebTest.php
继承人的输出覆盖XML文件:
<?xml version="1.0" encoding="UTF-8"?>
<coverage generated="1341015508">
<project timestamp="1341015508">
<metrics files="0" loc="0" ncloc="0" classes="0" methods="0" coveredmethods="0" conditionals="0" coveredconditionals="0" statements="0" coveredstatements="0" elements="0" coveredelements="0"/>
</project>
</coverage>
T他测试自己通过。
我已经验证有没有退出或代码的任何地方死语句。
任何想法?