Cucumber-场景标题中的变量,但在正文中不使用它



在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           |

正如你所看到的<excel_line>仅标题不同,不应在正文中使用。

这可能吗?

我可以在一个项目中找到一个我很满意的变通方法。这个变量被用在身体里,但至少看起来不是这样

执行如下步骤(在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           |

最新更新