定制 codeception/c3 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

codeception/c3

Composer 安装命令:

composer require codeception/c3

包简介

CodeCoverage collector for Codeception

README 文档

README

Issues | Usage Guide

Remote CodeCoverage for Codeception Build Status

This file c3.php should be included into the application you are testing in the very first line. It will start remote code coverage collection. Coverage data will be stored to disk and retrieved by codeception when tests from the suite are finished. This file won't affect your application in any way. It is executed only when a special header X-Codeception-CodeCoverage is sent. Alternatively, if you use Selenium, special cookie CODECEPTION_CODECOVERAGE is used. In any other case your application run as usually with no overheads.

Local Code Coverage

If you don't run tests on remote server but use a webserver (Apache, Nginx, PhpWebserver) you need c3.php installed just the same way. In this case coverage result will be merged with local code coverage.

Installation

File c3.php should be put in project root, into the same directory where codeception.yml config is located. Also, make sure Codeception is available on remote server either in phar/pear/composer packages.

Via Composer

Add to composer.json:

"require-dev": {
    "codeception/codeception": "3.*",
    "codeception/c3": "2.*"
}

C3 installer will copy c3.php to the project root.

Manually

wget https://raw.github.com/Codeception/c3/2.0/c3.php

Setup

Now you should include c3.php in your front script, like index.php.

Example file: web/index.php:

<?php

define('C3_CODECOVERAGE_ERROR_LOG_FILE', '/path/to/c3_error.log'); //Optional (if not set the default c3 output dir will be used)
include '/../c3.php';

define('MY_APP_STARTED', true);
// App::start();
?>

Now on when is Codeception launched with code coverage enabled you will receive a coverage report from this remote server.

Configuration

To enable remote (and local) codecoverage by c3.script you should edit global configuration file codeception.yml, or one of the suite configuration files.

Example: codeception.yml

coverage:
  enabled: true
  remote: true
  include:
    - app/*
  exclude:
    - app/cache/*

The remote option specifies if you run your application actually runs on another server. If your webserver runs on the same node and uses the same codebase, disable this option.

Predefined Routes

c3 file shouldn't break your application, but there are predefined routes that will be managed by c3. Codeception will access routes in order to receive collected coverage report in different formats.

  • c3/report/clover
  • c3/report/serialized
  • c3/report/html
  • c3/report/clear

Debug

In case you got into troubles and remote debugging still doesn't start you can try the following. Edit c3.php file and remove the header check

// to remove
if (!array_key_exists('HTTP_X_CODECEPTION_CODECOVERAGE', $_SERVER)) {
    return;
}

then add this line to the top of file:

$_SERVER['HTTP_X_CODECEPTION_CODECOVERAGE_DEBUG'] = 1;

now access http://yourhost/c3/report/clear url and see if it has errors. Please check that error_reporting is set to E_ALL

Temp directories

In root of your project c3tmp dir will be created during code coverage. It will not be deleted after suite ends for testing and debugging purposes. Serialized data as well as xml and html code coverage reports will be stored there.

codeception/c3 适用场景与选型建议

codeception/c3 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 5.57M 次下载、GitHub Stars 达 74, 最近一次更新时间为 2014 年 10 月 02 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「codecoverage」 「code coverage」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 codeception/c3 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 codeception/c3 我们能提供哪些服务?
定制开发 / 二次开发

基于 codeception/c3 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 5.57M
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 74
  • 点击次数: 23
  • 依赖项目数: 96
  • 推荐数: 0

GitHub 信息

  • Stars: 74
  • Watchers: 10
  • Forks: 46
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-10-02