未生成以下步骤的 Behat / Mink 错误代码段

Behat / Mink error Snippets for the following steps not generated

在 v3 中从 Behat 切换到 Mink 以使用无头浏览器进行测试时。它停止从我的功能文件自动为我生成代码段。

遵循文档中 features/bootstrap/FeatureContext.php 的设置。

behat

# generates this error at the bottom of the output
--- Snippets for the following steps in the default suite were not generated (check your configuration)

在它输出我需要设置的功能之前的 Behat 风格。

在摸索和研究其他一些站点示例后找到了答案。 Drupal 的使用是有帮助的。

出于某种原因,Mink 现在并不打算为您做这件事,您要自己实施它们,这看起来很奇怪,他们应该将其添加到文档中。

所有需要做的就是包括命名空间和 "implement" 它,然后一切都很好

https://behat-drupal-extension.readthedocs.org/en/3.0/localinstall.html

添加到 features/bootstrap/FeatureContext。php

use Behat\Behat\Context\SnippetAcceptingContext;

并且在你的 class def "implements SnippetAcceptingContext"

的末尾
class FeatureContext extends MinkContext implements SnippetAcceptingContext

然后所有工作再次显示何时执行或将自动添加到文件

behat --append-snippets

你会在输出的末尾看到类似

的内容
u features/bootstrap/FeatureContext.php - `I should see "count" greater than "10"` definition added

SnippetAcceptingContext 已弃用,将在 4.0 版中删除。请改用 behat --snippets-for CLI 选项。