drevops/behat-steps

Behat 步骤集合


README

Behat steps logo

Drupal 的 Behat 步骤集合

GitHub Issues GitHub Pull Requests CircleCI codecov GitHub release (latest by date) LICENSE Renovate

Total Downloads

安装

composer require --dev drevops/behat-steps:^2

用法

将所需的特性添加到您的 FeatureContext.php 中(示例

<?php

use Drupal\DrupalExtension\Context\DrupalContext;
use DrevOps\BehatSteps\ContentTrait;

/**
 * Defines application features from the specific context.
 */
class FeatureContext extends DrupalContext {

  use ContentTrait;

}

不需要修改 behat.yml 配置。

异常

  • \Exception 在所有断言中抛出。
  • \RuntimeException 在步骤中未满足的任何要求抛出。

可用步骤

跳过场景之前的钩子

某些特性提供了 beforeScenario 钩子实现。可以通过在测试中添加 behat-steps-skip:METHOD_NAME 标签来禁用它们。

例如,要跳过 beforeScenario 钩子从 JsTrait,将 @behat-steps-skip:jsBeforeScenarioInit 标签添加到功能中。

开发

本地环境设置

使用 ahoy --help 查看可用命令列表。

Apple Silicon 调整

cp docker-compose.override.default.yml docker-compose.override.yml

运行测试

通过在项目中以相同的方式运行 Behat 测试来测试特性的源代码:特性被包含在 FeatureContext.php 中,然后使用 预配置的 fixture Drupal 网站使用测试功能 运行。

运行 ahoy build 以在 build 目录中设置 fixture Drupal 网站。

ahoy test-bdd                # Run all tests

ahoy test-bdd path/to/file   # Run all scenarios in specific feature file

ahoy test-bdd -- --tags=wip  # Run all scenarios tagged with `@wip` tag

调试测试

  • ahoy debug
  • 设置断点
  • 使用 ahoy test-bdd 运行测试 - 您的 IDE 将捕获传入的调试连接

更新 fixture 网站

  • 构建 fixture 网站并进行必要的更改
  • ahoy drush cex -y
  • 使用 ahoy update-fixtures 将配置更改从构建目录复制到 fixtures 目录

使用 https://getscaffold.dev/ 项目模板创建的仓库