matthiasnoback/behat-remote-code-coverage-extension 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

matthiasnoback/behat-remote-code-coverage-extension

最新稳定版本:v0.4.1

Composer 安装命令:

composer require matthiasnoback/behat-remote-code-coverage-extension

包简介

README 文档

README

This extension can be used to collect code coverage data from the web server that's called by Mink while running Behat.

To use this extension, enable it under extensions and for every suite that needs remote code coverage collection, set remote_coverage_enabled to true.

default:
    extensions:
        BehatRemoteCodeCoverage\RemoteCodeCoverageExtension:
            target_directory: '%paths.base%/var/coverage'
    suites:
        default:
            remote_coverage_enabled: true

Now modify the front controller of your web application to look like this:

use LiveCodeCoverage\RemoteCodeCoverage;

$shutDownCodeCoverage = RemoteCodeCoverage::bootstrap(
    (bool)getenv('CODE_COVERAGE_ENABLED'),
    sys_get_temp_dir(),
    __DIR__ . '/../phpunit.xml.dist'
);

// Run your web application now...

// This will save and store collected coverage data:
$shutDownCodeCoverage();

Make sure to modify the call to RemoteCodeCoverage::bootstrap() if needed:

  1. Provide your own logic to determine if code coverage should be enabled in the first place (this example uses an environment variable for that). This is important for security reasons. It helps you make sure that the production server won't expose any collected coverage data.
  2. Provide your own directory for storing the coverage data files (.cov).
  3. Provide the path to your own phpunit.xml(.dist) file. This file is only used for its code coverage filter configuration.

After a test run, the extension makes a special call (/?code_coverage_export=true&...) to the web application. The response to this call contains the serialized code coverage data. It will be stored as a file in target_directory, named after the test suite itself, e.g. default.cov.

You can use these .cov files to generate nice reports, using phpcov.

You could even configure PHPUnit to generate a .cov file in the same directory, so you can combine coverage data from PHPUnit and Behat in one report.

To (also) generate (local) code coverage during a Behat test run, use the LocalCodeCoverageExtension.

统计信息

  • 总下载量: 350.07k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 14
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 14
  • Watchers: 1
  • Forks: 7
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-02-07