堡垒/Behat上下文

Behat上下文

0.1.2 2022-10-19 08:52 UTC

This package is auto-updated.

Last update: 2024-09-19 13:22:38 UTC


README

Behat上下文提供了最常用的Behat测试。

安装

此扩展需要

  • Mink
  • Mink扩展

项目依赖

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

项目引导

  1. 使用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"

翻译

See more information on Transifex.com