gpt4 book ai didi

java - cucumber /小 cucumber - 将 "When"项放在 "Background"内是否可以接受?

转载 作者:行者123 更新时间:2023-12-02 02:09:55 24 4
gpt4 key购买 nike

我的 Cucumber/Gherkin 测试涵盖了一些基本的创建和删除,但是第一个场景涵盖的过程是后续场景的先决条件。

例如:如果我们有一辆新车,并且在某种数组中找到了内容(最初是空的,因为它是新的)

Scenario: Adding an item to the car
Given I have bought a new car
When I add fluffy dice to the mirror
Then There should be fluffy dice found in the car

Scenario: Removing an item from the car
Given I have bought a new car
When I add fluffy dice to the mirror
And I remove fluffy dice from the mirror
Then There should be no items found in the car

Scenario: Add multiple items to the car
Given I have bought a new car
When I add fluffy dice to the mirror
And I a bobble head to the dashboard
Then there should be 2 items in the car

我知道我可以将 Given I have buy a new car 抽象为 Background:,但是添加 When I add fluffy dice 怎么样?到镜子,因为这在所有场景中都存在?

最佳答案

是的,这是可行的 - 您基本上只需更改时间和))

Background: 
Given I have bought a new car
And I add fluffy dice to the mirror

关于java - cucumber /小 cucumber - 将 "When"项放在 "Background"内是否可以接受?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50176677/

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