The basic Behat use case recommends using FeatureContext
class. Also, you can specify any other PHP classes in the features/bootstrap
directory and they are loaded, but in the alphabetical order, no matter what the dependencies are.
Given there is a trait and a FeatureContext class:
features/bootstrap/FeatureContext.php
features/bootstrap/MyLovelyTrait.php
What is the best way to load it properly? Obviously, MyLovelyTrait is used within the FeatureContext:
class FeatureContext extends BehatContext {
use MyLovelyTrait;
}
And that fails because M > F
, in the alphabet.
I will be happy to use composer autoloading, but I don't want to require_once
the autoload.php
file in the top of BehatContext.php
file. Is there a way to specify this in behat.yml
configuration? Also, any other best practice answer regarding class-loading of Behat context files will be appreciated.