我有一个 Behat.yml
default :
context :
parameters :
user: xyz
password : abc
我还有一个名为 FeatureContext.php 的文件,它通过以下方式从 behat.yml 检索值
public function iExample($user, $password)
{
$userName=$this->getParameter($user);
}
但它会抛出一个错误,比如
"Call to undefined method FeatureContext::getParameter()"
我错过了什么吗? ..我还在FeatureContext.php中添加了autoload.php
require_once __DIR__.'/../../vendor/autoload.php';
如果您知道为什么会发生这种情况,请告知?
Your FeatureContext
班级必须延长BehatContext
然后你得到参数数组作为构造函数中的参数FeatureContext
. See http://michaelheap.com/behat-selenium2-webdriver/举个例子。
Edit:
class FeatureContext extends BehatContext
{
private $params = array();
public function __construct(array $parameters)
{
$this->params = $parameters;
}
public function iExample($user, $password)
{
$userName = $this->params['user'];
}
}
我已经有一段时间没有使用 Behat 了,但你可能已经明白了。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)