在钩子之后访问黄瓜中的场景标题和示例

如何从After钩子中获取Ruby黄瓜测试中的当前Example

我可以使用下面的代码获得标题。 我的Scenario有几个Examples 。 我可以访问当前正在测试的Example吗?

function文件

 Scenario Outline: Successful login with primary accounts Given I start on the login page When I log into Overview page with "" Then I am on the Overview page Examples: | acct | | account1 | | account2 | 

钩后

 After do |scenario| scenario.scenario_outline.title # will give me the title 

如何获取当前Example

我是这样做的。

  scenario_title = scenario.respond_to?(:scenario_outline) ? scenario.scenario_outline.title : '' scenario_title_example = scenario.respond_to?(:name) ? scenario.name : '' scenario_full_title = scenario_title + scenario_title_example