Is there a way how to get tags for a scenario in Behat FeatureContext in which the method is being run in?
@SPRF1
Scenario: My scenario
Given something is done
class FeatureContext implements \Behat\Behat\Context\Context
{
/**
* @Then something is done
*/
public function somethingIsDone()
{
$tags = $this->getScenarioTags(); // this doesn't exist
}
}
You should use a BeforeScenarioScope
hook.
Try something like this:
/**
* @BeforeScenario
*/
public function getTestId(BeforeScenarioScope $scope)
{
$tags = $scope->getScenario()->getTags();
}
Don't forget to add use Behat\Behat\Hook\Scope\BeforeScenarioScope;