【问题标题】:How to get tags in Behat FeatureContext如何在 Behat FeatureContext 中获取标签
【发布时间】:2018-03-27 07:48:18
【问题描述】:

有没有办法在 Behat FeatureContext 中获取运行该方法的场景的标签?

my.feature

  @SPRF1
  Scenario: My scenario
    Given something is done

FeatureContext

class FeatureContext implements \Behat\Behat\Context\Context
{
    /**
     * @Then something is done
     */
    public function somethingIsDone()
    {
        $tags = $this->getScenarioTags(); // this doesn't exist
    }
}

【问题讨论】:

    标签: php testing behat


    【解决方案1】:

    您应该使用BeforeScenarioScope 挂钩。 试试这样的:

        /**
         * @BeforeScenario
         */
        public function getTestId(BeforeScenarioScope $scope)
        {
            $tags = $scope->getScenario()->getTags();
        }

    别忘了加use Behat\Behat\Hook\Scope\BeforeScenarioScope;

    【讨论】:

      猜你喜欢
      • 2023-04-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多