问题描述
在 Cucumber 中,我想在标题中使用变量而不在正文中使用它。 例如:
Scenario Outline: Test case described at <excel_line>
Given the following devices
| name | type |
| device | <device> |
When a <device> is active
Then I get a message
Examples:
| device | excel_line |
| Android | 1 |
| IPhone | 2 |
如您所见,
这可能吗?
解决方法
我可以在一个项目中找到我满意的解决方法。 变量用在正文中,但至少看起来不是这样。
执行如下步骤(如果是 Ruby)
Given('Scenario title: {string}') do |scenario_title|
puts "scenario_title : #{scenario_title}"
end
然后:
Scenario Outline:
* Scenario title: Test case described at <excel_line>
Given the following devices
| name | type |
| device | <device> |
When a <device> is active
Then I get a message
Examples:
| device | excel_line |
| Android | 1 |
| IPhone | 2 |