0

I'm using behat with the mink extension to run fonctionnal tests. I've got a FeatureContext, extending the MinkContext.

I'm trying to pass custom parameters to my context, but I'm not really sure how. My idea was to put them in the behat.yml and then access them using Symfony's container, but I don't know how to access it from my FeatureContext.

Thanks

David
  • 33,444
  • 11
  • 80
  • 118

1 Answers1

1

As docs say:

parameters is a simple array that will be passed into the constructor of your context class when instantiated, which happens before each scenario.

That means that parameters defined in your behat.yml:

default:
    context:
        parameters:
            my_parameter: my_value

are passed to your context via a constructor:

class FeatureContext extends RawMinkContext
{
    private $parameters = array();

    public function __construct(array $parameters)
    {
        $this->parameters = $parameters;
    }
}

If your intention was to alter parameters from the Symfony container, you should rather do it in one of the Symfony configuration files (you should be running behat agains test environment, this way configuration is separate from dev and prod).

Jakub Zalas
  • 35,761
  • 9
  • 93
  • 125