gpt4 book ai didi

ruby - 背景中的 cucumber

转载 作者:太空宇宙 更新时间:2023-11-03 16:54:09 24 4
gpt4 key购买 nike

这是一个关于 cucumber 的棘手问题:

Feature: Some feature

Background:
Given I am on the root page

Scenario Outline: Relevant flash messages should appear
When I fill in some_field with: <name>
Then I should see the text: <relevant_flash>

Examples:
| name | relevant_flash |
| Some name | Some message |

Scenario Outline: Irrelevant flash messages should not appear
When I fill in some_field with: <name>
Then I should not see the text: <irrelevant_flash>

Examples:
| name | irrelevant_flash |
| Some name | Some message |

我讨厌重复:

 When I fill in some_field with: <name>

但由于显而易见的原因,它不能只是移到后台。或者可以吗?如果您有解决方法,请告诉我...

最佳答案

好吧,我可以用这样的东西来简化你的 cucumber :

Feature: Some feature

Scenario Outline: Relevant flash messages should appear
Given I am on the root page
When I fill in some_field with: <name>
Then I should see <message>
Examples:
| name | message |
| Some name | Relevant message |
| Some other name | Irrelevant message |
| Some another name | another flash message |

你注意到我去掉了Background:因为我们在Scenario Outline:中得到了它的覆盖我认为这些步骤将运行且简单,无需过多重复

关于ruby - 背景中的 cucumber <reference>?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13712449/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com