堡垒 / Behat上下文
Behat上下文
0.1.2
2022-10-19 08:52 UTC
Requires
- php: >=8.0
- ext-dom: *
- ext-libxml: *
- ext-simplexml: *
- behat/behat: ^3.8
- friends-of-behat/mink-extension: ^2.5
- justinrainbow/json-schema: ^5.2
- symfony/dom-crawler: ^4.4|^5.4|^6.0
- symfony/http-foundation: ^5.4|^6.0
- symfony/property-access: ^5.4|^6.0
Replaces
- behatch/contexts: 0.1.2
- sanpi/behatch-contexts: 0.1.2
README
Behat上下文提供了最常用的Behat测试。
安装
此扩展需要
- Mink
- Mink扩展
项目依赖
- 安装Composer
- 使用Composer安装此包
$ composer require --dev fortress/behat-contexts
- 通过在您的
behat.yml
中指定其类来激活扩展
# behat.yml default: # ... extensions: Behatch\Extension: ~
项目引导
- 使用Composer下载Behatch骨架
$ php composer.phar create-project behatch/skeleton
浏览器、json、table和rest步骤需要一个mink配置,更多详细信息请参阅Mink扩展。
使用方法
在 behat.yml
中启用所需的上下文
default: suites: default: contexts: - behatch:context:browser - behatch:context:debug - behatch:context:system - behatch:context:json - behatch:context:table - behatch:context:rest - behatch:context:xml
示例
此项目是自测试的,您可以探索features目录以查找一些示例。
配置
browser
- 更多浏览器相关步骤(如mink)timeout
- 默认超时
debug
- 调试辅助步骤screenshotDir
- 存储截图的目录
system
- 与shell相关的步骤root
- 文件系统的根目录
json
- JSON相关步骤evaluationMode
- JavaScript "foo.bar" 或 PHP "foo->bar"
table
- 在HTML表格中玩耍rest
- 发送GET、POST等请求并测试HTTP头xml
- XML相关步骤
配置示例
例如,如果您想将默认目录更改为截图,可以这样做
default: suites: default: contexts: - behatch:context:debug: screenshotDir: "var"