gpt4 book ai didi

cucumber - 我应该在 Gherkin/Specflow Give/When/Then 语句中使用什么人物和情绪?

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

我对人们用 Gherkin 语言编写语句来描述为验收测试执行的各种操作的方式感到有点困惑。

在某些文章中人们使用“I”,而在某些文章中人们使用“User”。

react (Then) 语句的情况也是如此:

Case 1 --> xyz page should be displayed
Case 2 --> xyz page is displayed

Ex 1:
Given statement abc
When user performs action A
Then screen xyz should be displayed

Ex 2:
Given statement abc
When I perform action A
Then screen xyz is displayed

写“用户”还是“我”更好,写“应该是”还是"is"更好,以便我的 BDD 场景能够按照标准呈现和正确?

对任何文章的引用也会有很大帮助。提前致谢。

最佳答案

两者都是正确的,并且有不同的好处。

BDD 的发明者 Dan North 表示,他更喜欢第一人称(“我”),因为这让他能够设身处地为用户着想。然而,他经常使用第三人称(“他/她/顾客”),就像他在 his introductory article 中所做的那样。 .

第一人称使用有助于使场景符合标准故事模板:

As <a stakeholder>
I want <something>
So that <goal>.

如果利益相关者是用户,那么在场景中再次使用“I”是有意义的。

但是,有时场景的结果并不真正有利于用户。

As the moderator of the site
I want users to prove that they're human
So that I can limit spam.

在这种情况下,将场景放在用户的角度来看会很奇怪,因为用户并不真正想要填写验证码框。我们可能会在这里使用第三人。

Given an odd-looking number "31" on a door frame
When the user identifies the number as "31"
Then the system should authenticate them as being human.

您可能还会发现,您有多个利益相关者,其结果很重要。在这种情况下,将场景放在第三人身上可以帮助发现可能未包括在内的任何其他结果或重要利益相关者。

Given Suzanne searches for a taxi for 4pm to take her to hospital
And the estimated price is $23
When she books the taxi
Then she should get a confirmation email
And the driver should be notified of the trip
And she should be charged $23.

因为苏珊娜、司机和 Uber 都参与了这个场景,所以将他们放在第三人中更有意义。

我倾向于更喜欢第三人称,特别是对于具有很多场景的大型产品,因为我发现切换第一人称角色很令人困惑,而且它可以保持一致性。这还意味着您可以为场景中的 Actor 起好记的名字,并更轻松地谈论他们(例如,“克拉伦斯·笨拙输入错误的电话号码”)。

但是,请记住,当您与利益相关者交谈以了解这些场景时,最重要的是对话。尽可能接近地写下他们的话,只有当你使用小 cucumber 重新措辞时,才会对语言做出妥协。

关于cucumber - 我应该在 Gherkin/Specflow Give/When/Then 语句中使用什么人物和情绪?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34839651/

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