相关疑难解决方法(0)

如何将未覆盖的文件添加到Yii应用程序的PHPUnit代码覆盖率报告中

我目前正在尝试获取基于Yii框架的PHP应用程序的代码覆盖率报告.

代码覆盖率由PHPUnit 3.6生成,我使用白名单方法来源文件过滤.

问题是,当我设置选项时addUncoveredFilesFromWhitelist="true",代码覆盖中断时出现以下错误:

Generating code coverage report, this may take a moment.PHP Warning:  include(CButtonColumn.php): failed to open stream: No such file or directory in /home/hijarian/systems/yii/framework/YiiBase.php on line 418
PHP Stack trace:
PHP   1. {main}() /usr/bin/phpunit:0
PHP   2. PHPUnit_TextUI_Command::main() /usr/bin/phpunit:46
PHP   3. PHPUnit_TextUI_Command->run() /usr/share/php/PHPUnit/TextUI/Command.php:125
PHP   4. PHPUnit_TextUI_TestRunner->doRun() /usr/share/php/PHPUnit/TextUI/Command.php:187
PHP   5. PHP_CodeCoverage_Report_HTML->process() /usr/share/php/PHPUnit/TextUI/TestRunner.php:373
PHP   6. PHP_CodeCoverage->getReport() /usr/share/php/PHP/CodeCoverage/Report/HTML.php:133
PHP   7. PHP_CodeCoverage_Report_Factory->create() /usr/share/php/PHP/CodeCoverage.php:141
PHP   8. PHP_CodeCoverage->getData() /usr/share/php/PHP/CodeCoverage/Report/Factory.php:65
PHP   9. PHP_CodeCoverage->processUncoveredFilesFromWhitelist() /usr/share/php/PHP/CodeCoverage.php:173
PHP  10. include_once() /usr/share/php/PHP/CodeCoverage.php:516 …
Run Code Online (Sandbox Code Playgroud)

php phpunit code-coverage yii

8
推荐指数
1
解决办法
5785
查看次数

仅生成刚刚测试过的内容

每次我运行一个类或整个文件夹的单元测试时,phpunit会为整个系统生成覆盖,因为它是在phpunit.xml中配置的.
这很糟糕,因为它需要更长的时间并耗尽PHP的内存.

我的phpunit.xml

<!-- http://www.phpunit.de/manual/current/en/appendixes.configuration.html -->
<phpunit
    backupGlobals               = "false"
    backupStaticAttributes      = "false"
    colors                      = "true"
    convertErrorsToExceptions   = "true"
    convertNoticesToExceptions  = "true"
    convertWarningsToExceptions = "true"
    processIsolation            = "false"
    stopOnFailure               = "false"
    syntaxCheck                 = "false"
    bootstrap                   = "Bootstrap.php" >

    <testsuites>
        <testsuite name="Application Module Suite Test">
            <directory>./Module1Test</directory>
            <directory>./Module2Test</directory>
            <directory>./Module3Test</directory>
        </testsuite>
    </testsuites>

    <filter>
        <whitelist>
            <directory>../module/Module1</directory>
            <directory>../module/Module2</directory>
            <directory>../module/Module3</directory>
        </whitelist>
    </filter>

</phpunit>
Run Code Online (Sandbox Code Playgroud)

有没有一种方法来生成的唯一的东西我测试现在,覆盖动态

示例
对于下面的命令,我想Controller/ExampleController.php仅为路径生成coverage .

phpunit Controller/ExampleController.php --coverage-html ~/Desktop/tests
Run Code Online (Sandbox Code Playgroud)

我正在使用PHPUnit 4.8和3.7,Sublime Text Editor,应用程序正在使用Zend Framework 2.

php phpunit zend-framework2

8
推荐指数
1
解决办法
858
查看次数

标签 统计

php ×2

phpunit ×2

code-coverage ×1

yii ×1

zend-framework2 ×1