Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a getScenario method to BeforeStepScope and AfterStepScope #653

Closed
cboyden opened this issue Nov 9, 2014 · 7 comments
Closed

Add a getScenario method to BeforeStepScope and AfterStepScope #653

cboyden opened this issue Nov 9, 2014 · 7 comments
Labels

Comments

@cboyden
Copy link

cboyden commented Nov 9, 2014

This would fix the issue reported in #650 - you could call $scope->getScenario()->hasTag() to check for the tag.

@stmllr
Copy link

stmllr commented Mar 20, 2015

The interface StepScope should provide an API for getting the scenario.

StepScope has an API for feature but not for scenario, though I would expect that from the structure feature -> scenario -> step

@kwisatz
Copy link

kwisatz commented Apr 21, 2015

👍

1 similar comment
@fugi
Copy link

fugi commented Jun 17, 2015

👍

@rebajz
Copy link

rebajz commented Feb 28, 2016

I am looking forward to it so much. I need insert scenario name to screenshot name... ;-)
@afterstep (afterStepScope)

@Taluu
Copy link
Contributor

Taluu commented Feb 29, 2016

cf #795

@romaricdrigon
Copy link

Another way is :

            /** @var \Behat\Gherkin\Node\ScenarioNode $scenario */
            $scenario = current($scope->getFeature()->getScenarios());

Having a public method would a be must-have though. Event if it implements one of the "hacks" at the moment.

@Taluu
Copy link
Contributor

Taluu commented Feb 29, 2016

The following is what I'm using currently ;

<?php
class FeatureContext {
     // snip

    private function getScenario(StepScope $scope)
    {
        $scenario = null;

        $feature = $scope->getFeature();
        $step = $scope->getStep();
        $line = $step->getLine();

        foreach ($feature->getScenarios() as $tmp) {
            if ($tmp->getLine() > $line) {
                break;
            }

            $scenario = $tmp;
        }

        return $scenario;
    }
}

In my features context file.

@everzet everzet closed this as completed Jul 24, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

8 participants