【问题标题】:Accessing the Scenario Title and Example in a Cucumber After hook在 Cucumber After hook 中访问场景标题和示例
【发布时间】:2015-12-29 00:08:02
【问题描述】:

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

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

功能文件

Scenario Outline: Successful login with primary accounts
  Given I start on the login page
  When I log into Overview page with "<acct>"
  Then I am on the Overview page   

Examples:
| acct          |
| account1      | 
| account2      |

挂钩后

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

如何获得当前的Example

【问题讨论】:

    标签: ruby cucumber calabash-android


    【解决方案1】:

    这是我的做法。

      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
    

    【讨论】:

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