Michael Szymczak
Michael Szymczak

Reputation: 1326

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

I use Symfony2 BehatBundle, version=v1.0.0 and I want to change the name of the main feature context file. Now when I run the behat using command:

app/console --env=test behat @NameOfMyBundle

file src/NameOfMyBundle/Features/Context/FeatureContext.php is used

I want to use custom main feature file, for example src/NameOfMyBundle/Features/Context/MyCustomContext.php but I don't know how. According to the behat documentation:

By convention, the context class should be called FeatureContext, but this could be easily changed through the cli configuration.

However, this configuration option is nowhere to be found. I tried something like:

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

but it fails.

Does anyone know how to change this main feature context file (preferably, using cli)?

Thanks!

Upvotes: 0

Views: 928

Answers (1)

Jakub Zalas
Jakub Zalas

Reputation: 36201

The context class can be changed in the configuration file: http://docs.behat.org/guides/7.config.html#context

Environment variables can be used as well: http://docs.behat.org/guides/7.config.html#environment-variable

The bundle is no longer maintained. Use the extension instead: http://docs.behat.org/en/latest/cookbooks/1.symfony2_integration.html#installing-and-enabling-symfony2-extension

Upvotes: 1

Related Questions