定制 deminy/behat-rest-testing 二次开发

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

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

deminy/behat-rest-testing

最新稳定版本:3.0.2

Composer 安装命令:

composer require deminy/behat-rest-testing

包简介

Demo on doing feature tests with Behat 3 and how to start writing feature tests for REST APIs.

README 文档

README

Build Status Latest Stable Version Latest Unstable Version License

This repo is to help developers to easily understand how to do feature tests with Behat, and to start writing feature tests for REST APIs, with following features included:

  • Core contexts/steps for testing REST APIs.
  • Sample RESTful services, and sample feature tests against the services.
  • Best of all: To start writing feature tests for the project you are working on, you may use this repo in your project via Composer if you happen to use Composer to manage 3rd-party libraries.

NOTE: Following instructions focus on Behat 3.0.6+ and PHP 5.4+. If you use Behat 2.x and/or PHP 5.3 (5.3.3+), please check branch "1.x" for details.

Dependencies

Branch master

Branch 1.x (old releases for Behat 2.x)

Installation - Source

You will need to download Composer and run the install command under the same directory where the 'composer.json' file is located:

curl -s http://getcomposer.org/installer | php && ./composer.phar install

Installation - Composer

You may also install using Composer if you want to use this repo in your own project.

Step 1. Add the repo as a dependency.

"require": {
    "deminy/behat-rest-testing": "~3.0.0"
}

NOTE: This is for running with Behat 3 only. If you use Behat 2.x, please check installation instructions for v1.x for details.

Step 2. Run Composer: php composer.phar install.

How to Test

1. Set up and run REST API server.

You can have a virtual host set up under Apache, with DocumentRoot set to "www/" of this repo and DirectoryIndex set to "router.php". Please make sure that module mod_rewrite is enabled, otherwise the REST server won't be able to handle requests properly. You may also need to update option "base_url" in the configuration file "behat.yml".

Alternatively, you may consider to use the PHP 5.4+ built-in web server.

To start the REST API server using PHP 5.4+ built-in web server, please run command similar to following:

php -S localhost:8081 www/router.php

The web server now serves as the REST API server. You can visit URL http://localhost:8081 to see if the server runs properly or not (If everything is good, the URL should return string "OK" back).

2. Create the configuration file "behat.yml" (optional).

For the sample test provided, you can create the file by copying directly from file "behat.yml.dist" without any modifications required.

Note that you don't have to do this if you prefer to use file "behat.yml.dist" directly.

3. Run the test command.

Now, run following command to test sample features:

./vendor/bin/behat
# OR
./vendor/bin/behat -p default # explicitly to use profile "default"

If everything is good, you should see the output as in following screenshot:

output when running Behat sample tests

TODOs

  • Support different environments (development, QA, staging, production, etc).

License

MIT license.

deminy/behat-rest-testing 适用场景与选型建议

deminy/behat-rest-testing 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 20.76k 次下载、GitHub Stars 达 77, 最近一次更新时间为 2014 年 11 月 13 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 deminy/behat-rest-testing 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 20.76k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 77
  • 点击次数: 17
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 77
  • Watchers: 5
  • Forks: 14
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-11-13