如何更改 Symfony2 Behat Bundle 默认的功能上下文文件(默认情况下.php功能上下文)


How to change the Symfony2 Behat Bundle default Feature context file (FeatureContext.php by default)

我使用Symfony2 BehatBundle,version=v1.0.0,我想更改主要功能上下文文件的名称。现在,当我使用命令运行behat时:

app/console --env=test behat @NameOfMyBundle

文件 src/NameOfMyBundle/Features/Context/FeatureContext.php 被使用

我想使用自定义主功能文件,例如 src/NameOfMyBundle/Features/Context/MyCustomContext.php但我不知道怎么做。根据 behat 文档:

按照惯例,上下文类应该称为 FeatureContext,但这可以通过 cli 配置轻松更改。

但是,找不到此配置选项。我尝试了类似的东西:

app/console --env=test behat @NameOfMyBundle --context "MyCustomContext"

但它失败了。

有谁知道如何更改此主要功能上下文文件(最好使用 cli(?

谢谢!

可以在配置文件中更改上下文类:http://docs.behat.org/guides/7.config.html#context

也可以使用环境变量:http://docs.behat.org/guides/7.config.html#environment-variable

不再维护捆绑包。请改用扩展名:http://docs.behat.org/en/latest/cookbooks/1.symfony2_integration.html#installing-and-enabling-symfony2-extension