我想更改步骤定义,例如
Scenario: eat 5 out of 12
Given there are 12 cucumbers
When I eat 5 cucumbers
Then I should have 7 cucumbers
要,
Scenario: eat 5 out of 12
Given there are 12 $(FOOD)
When I eat 5 $(FOOD)
Then I should have 7 $(FOOD)
这样我可以像我一样运行黄瓜,
FOOD=cucumbers ./cucumber-launch-script.sh
一切都按预期工作。
答案 0 :(得分:0)
您可以这样做,但环境变量只能用于代码,即步骤定义和辅助方法。
这意味着你的输出只会谈论食物,而你的步骤将是谈论橙子和苹果。
这可以像
那样工作 Given there are 12 food
由
实施
Given 'there are 12 food' do
12.times {create_food)
end
和辅助方法
def create_food
type_of_food = get food from ENV
...
end
将环境变量转换为功能的唯一方法是在运行黄瓜之前对它们进行预处理,我无法看到Cucumber支持这种功能。