Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting feature file path within BehatContext

Tags:

php

bdd

behat

I have a FeatureContext class, whose methods implement step definitions for my feature scenarios.

Is it possible to obtain information about current scenario or feature within FeatureContext class? To be specific, I need the path of the feature file, so I can create directory paths relative to dirname('file.feature').

The context class resides somewhere in vendor directory structure, i.e. far away from the actual feature file, so getting the path using __DIR__ would not work.

Any ideas?

Thanks, Sascha

like image 961
DrSchimke Avatar asked Jul 14 '26 05:07

DrSchimke


1 Answers

I did find an answer to my question: "hooks"

class MyContext implements Context
{
    // ...

    /**
     * @BeforeScenario
     */
    public function beforeScenario(BeforeScenarioScope $scope)
    {
        var_dump($scope->getFeature()->getFile());
    }
}
like image 55
DrSchimke Avatar answered Jul 21 '26 19:07

DrSchimke