svetel/behatch-contexts

复活了废弃的 "Behatch contexts"。

安装数: 3,593

依赖: 0

建议: 0

安全: 0

星标: 0

关注者: 0

分支: 203

开放问题: 0

语言:Gherkin

4.0.2 2023-03-15 14:05 UTC

README

构建状态 StandWithUkraine Stand With Ukraine Behatch contexts 提供了最常用的 Behat 测试。

该项目是从 Behatch/contexts 分支出来的

  • 添加了对 PHP 8.1 的支持
  • 修复了弃用
  • 修复了所有标签的测试,除了
    • @user
    • @skip
    • @javascript

欢迎贡献力量

安装

此扩展需要

  • Behat 3+
  • Mink
  • Mink 扩展

项目依赖

  1. 安装 Composer
  2. 使用 Composer 需求包
$ composer require --dev svetel/behatch-contexts
  1. 通过在您的 behat.yml 中指定其类来激活扩展
# behat.yml
default:
    # ...
    extensions:
        Behatch\Extension: ~

项目启动

  1. 使用 Composer 下载 Behatch 模板
$ php composer.phar create-project behatch/skeleton

浏览器、json、表格和 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"