【发布时间】:2013-08-31 10:42:18
【问题描述】:
我在为 Behat 中的 BDD 功能和 Yii 框架中的 Mink 设置定义自己的步骤时遇到了问题。
我已经按照MinkExtension-example 的说明成功安装了带有 Mink 扩展的 Behat。
毕竟,我在 myapp/private_html/ 中的文件夹结构如下(省略了一些深度嵌套的文件夹):
├───bin
├───commands
│ └───shell
├───components
├───config
├───controllers
├───features
│ ├───bootstrap
│ └───php54_bootstrap
├───models
├───tests
├───vendor
│ ├───behat
│ │ ├───behat
│ │ │ ├───bin
│ │ │ ├───features
│ │ │ │ ├───annotations
│ │ │ │ ├───bootstrap
│ │ │ │ └───closures
└───views
上述链接MinkExtension-example 中作为示例提供的功能可以正常工作。但是当我定义自己的步骤时,就像
Scenario: presence of menu items
Given I am on "/"
Then I should see the following: "Home, About, Contact"
我明白了
1 scenario (1 undefined)
2 steps (1 passed, 1 undefined)
0m2.288s
有建议
You can implement step definitions for undefined steps with these snippets:
/**
* @Then /^I should see the following: "([^"]*)"$/
*/
public function iShouldSeeTheFollowing($arg1)
{
throw new PendingException();
}
问题是:我应该把这段代码放在哪里?我试着把它放进去
myapp\private_html\features\bootstrap\FeatureContext.php
还有
myapp\private_html\vendor\behat\behat\features\bootstrap\FeatureContext.php
但该步骤仍未定义。
那么,应该在哪里定义步骤?
【问题讨论】: