Skip to content

getScenario() has to return a Scenario but returns an ExampleNode so the getTitle() function didn't works as expected #1470

@cavo789

Description

@cavo789

Hi all

I've multiple scenarios and some are Scenario Outline.

I'm using a hook for @BeforeScenario like

public function beforeScenario(BeforeScenarioScope $scope): void 
{
}

Below my debugging session in vscode:

image

We can see $scope is well a BeforeScenarioScope and in my console, $scope->getScenario() is returning an ExampleNode and that's wrong since the docblock for getScenario() tells it should be a Scenario

File src/Behat/Behat/Hook/Scope/BeforeScenarioScope.php

    /**
     * Returns scenario.
     *
     * @return Scenario
     */
    public function getScenario()
    {
        return $this->scenario;
    }

(the docblock is not correct)

By dumping the $scope object, we can see there is a private attribute outlineTitle and I've retrieved a getOutlineTitle() so I'm unblocked...

But it is normal? I'll need to check if I'm facing a Scenario or an ExampleNode and depending on what, use getTitle() in the first case and getOutlineTitle() in the second case.

Tanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions