Behat 停止为方法存根生成正则表达式
Behat stopped generating regular expressions for method stubs
我已经开始与 Behat 合作进行行为测试。
我成功地为我的 Symfony2 项目做好了准备,开始编写场景。我很高兴 Behat 为我提供了带有正则表达式的方法存根以填充与我场景中的步骤相对应的内容。
然而,一段时间后,Behat 停止生成正则表达式并给我这样的存根方法:
/**
* @Given I am on the page :arg1 <-- this is what I get
*/
public function iAmOnThePage($arg1)
{
throw new PendingException();
}
我宁愿让它像以前一样工作,例如:
/**
* @Given /^I open "([^"]*)"$/ <--- I'd expect this
*/
public function iOpen($arg1, $sessionName=null)
{
$this->getSession($sessionName)->visit($arg1);
}
我一定是在去的时候搞砸了一些事情,但不知道为什么默认行为突然改变了。
有什么建议吗?
您更新 Behat 版本了吗?
在版本 3 中,它与 :arg
一起使用,而在 v2.5 中,它与正则表达式一起使用。
如果您喜欢旧的工作方式,可以遵循 manual .
Implementing the SnippetAcceptingContext interface tells Behat that
your context is expecting snippets to be generated inside it. Behat
will generate simple pattern snippets for you, but if regular
expressions are your thing, Behat can generate them instead if you
implement Behat\Behat\Context\CustomSnippetAcceptingContext interface
instead and add getAcceptedSnippetType() method returning string
"regex":
public static function getAcceptedSnippetType()
{
return 'regex';
}
我已经开始与 Behat 合作进行行为测试。
我成功地为我的 Symfony2 项目做好了准备,开始编写场景。我很高兴 Behat 为我提供了带有正则表达式的方法存根以填充与我场景中的步骤相对应的内容。
然而,一段时间后,Behat 停止生成正则表达式并给我这样的存根方法:
/**
* @Given I am on the page :arg1 <-- this is what I get
*/
public function iAmOnThePage($arg1)
{
throw new PendingException();
}
我宁愿让它像以前一样工作,例如:
/**
* @Given /^I open "([^"]*)"$/ <--- I'd expect this
*/
public function iOpen($arg1, $sessionName=null)
{
$this->getSession($sessionName)->visit($arg1);
}
我一定是在去的时候搞砸了一些事情,但不知道为什么默认行为突然改变了。
有什么建议吗?
您更新 Behat 版本了吗?
在版本 3 中,它与 :arg
一起使用,而在 v2.5 中,它与正则表达式一起使用。
如果您喜欢旧的工作方式,可以遵循 manual .
Implementing the SnippetAcceptingContext interface tells Behat that your context is expecting snippets to be generated inside it. Behat will generate simple pattern snippets for you, but if regular expressions are your thing, Behat can generate them instead if you implement Behat\Behat\Context\CustomSnippetAcceptingContext interface instead and add getAcceptedSnippetType() method returning string "regex":
public static function getAcceptedSnippetType()
{
return 'regex';
}