rmiller/behat-spec
Composer 安装命令:
composer require rmiller/behat-spec
包简介
Behat and PhpSpec integration
README 文档
README
What
Integration between Behat and PhpSpec.
- Creates specs for any missing classes encountered when running behat
- Adds examples for any missing methods encountered when running behat
- Executes the phpspec run command after this to add the described class/method
Why
This is useful when rather than using the Behat context to run an application through its UI, it is instead used to implement the domain model. For more information on this way of using Gherkin features to drive domain modelling read Everzet's post on Modelling by Example
When running a feature with a Context that contains a new class that does not exist or a method you will get a fatal error. If using PhpSpec the next step would be to start specifying that class using the describe command. This set of extensions provides integration between Behat and PhpSpec so that instead of a fatal error you can choose to run the describe command for the missing class automatically.
It also uses my ExemplifyExtension so that you can automatically add examples for missing methods in a similar way.
After describing a class or method in this way the phpspec run command can
be used to automatically create the class or model. Since this is the typical
next step in most cases, this extension automates that by asking you if you would
like to do that next.
An Example
So to use an example from the blog post linked above:
/**
* @Given a product named :name and priced £:price was added to the catalogue
*/
public function aProductNamedAndPricedWasAddedToTheCatalogue($name, Money $price)
{
$aProduct = Product::namedAndPriced($name, $price);
$this->catalogue->add($aProduct);
}
Running the feature relating to this context would result in a fatal exception normally. Instead you get a simple error and the offer to create a spec for the missing class:
The spec is created followed by an offer to run phpspec run:
Which asks to create the class:
Running Behat again will result in a similar process for the namedAndPriced method.
Where an example for the method will be added to the spec and the method added
to the class.
How
Installation
This package provides an extension for PhpSpec and an extension for Behat. Both need to be enabled for the full functionality.
Requires:
- Behat 3.0+
- PhpSpec 3.0+
- PHP 5.6+
Require the extension:
$ composer require --dev rmiller/behat-spec:^0.5
In order to use BehatSpec with PHPSpec 2.0 series, use 0.3.* version series:
$ composer require --dev rmiller/behat-spec:0.3.*
To get the phpspec run command running, you need to use latest phpspec >2.1. Otherwise that functionality will silently fail.
Configuration
Activate the Behat extension by specifying its class in your behat.yml:
# behat.yml # ... extensions: RMiller\BehatSpec\Extension\BehatSpecExtension\BehatExtension: path: bin/phpspec #default value is bin/phpspec config: path/to/phpspec.yml #optional
Activate the PhpSpec extension by specifying its class in your phpspec.yml:
# phpspec.yml extensions: RMiller\BehatSpec\Extension\BehatSpecExtension\PhpSpecExtension: ~
Additional configuration can be provided for the running of the phpspec run command:
It defaults to bin/phpspec for the path of phpspec and to run after the describe command.
These can be overridden as follows:
# phpspec.yml rerunner: path: vendor/bin/phpspec commands: [describe, exemplify, your_own_fancy_command] config: path/to/phpspec.yml #optional extensions: RMiller\BehatSpec\Extension\BehatSpecExtension\PhpSpecExtension: ~
Some Details
This package pulls together some other PhpSpec and Behat extensions which can also be used standalone:
PhpSpec
Behat
rmiller/behat-spec 适用场景与选型建议
rmiller/behat-spec 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 21.71k 次下载、GitHub Stars 达 52, 最近一次更新时间为 2014 年 11 月 03 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「BDD」 「SpecBDD」 「StoryBDD」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 rmiller/behat-spec 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 rmiller/behat-spec 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 rmiller/behat-spec 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Scenario-oriented BDD framework for PHP
Helper that decorates any SUS with a phpspec lazy object wrapper
Behat Context for testing Symfony Api
Provides access to magento2 object manager from behat and allows to change magento config settings temporarly
DateTime approximate token allows you to write specs without 1second problem
Specification-oriented BDD helpers for PHPUnit
统计信息
- 总下载量: 21.71k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 53
- 点击次数: 18
- 依赖项目数: 9
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2014-11-03



