Sur*_*pta 4 bdd acceptance-testing cucumber specflow gherkin
我对人们用Gherkin语言编写语句以描述为验收测试执行的各种操作的方式感到困惑.
在一些文章中,人们使用"我",在一些文章中人们使用"用户".
对于reaction(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
Run Code Online (Sandbox Code Playgroud)
写"用户"或"我"是否更好,写"应该是"还是"是"更好,这样我的BDD场景是否符合标准?
对任何文章的引用也将是一个很大的帮助.提前致谢.
两者都是正确的,并且有不同的好处.
发明BDD的丹·诺斯说,他更喜欢第一人称("我"),因为这样他就可以把自己放在用户的鞋子里.但是,他经常使用第三人称("他/她/客户"),就像他在介绍性文章中所做的那样.
第一人称使用可以帮助使场景适合标准故事模板:
As <a stakeholder>
I want <something>
So that <goal>.
Run Code Online (Sandbox Code Playgroud)
如果利益相关者是用户,那么在场景中再次使用"I"是有意义的.
但是,有时情景的结果并不是为了用户的利益.
As the moderator of the site
I want users to prove that they're human
So that I can limit spam.
Run Code Online (Sandbox Code Playgroud)
在这种情况下,将场景放在用户的视角中会很奇怪,因为用户并不真的想填写该验证码框.我们可能在这里使用第三人称.
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.
Run Code Online (Sandbox Code Playgroud)
您可能还发现您拥有多个利益相关者,其结果非常重要.在这种情况下,将场景置于第三人可以帮助发现可能未包含的任何其他结果或重要利益相关者.
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.
Run Code Online (Sandbox Code Playgroud)
因为Suzanne,车手和优步都参与了这个场景,所以将他们放在第三人称更有意义.
我倾向于选择第三人,特别是对于有很多场景的大型产品,因为我发现必须切换第一人称角色令人困惑,并且它允许一致性.这也意味着你可以给场景中的演员留下令人难忘的名字并更容易地谈论它们(例如,克拉伦斯笨拙地用错误键入他的号码的那个).
但是,请记住,当您与利益相关者交谈以掌握这些情景时,最重要的是对话.尽可能地写下他们的单词,然后只有在使用Gherkin对其进行改写时才会破坏语言.
| 归档时间: |
|
| 查看次数: |
1071 次 |
| 最近记录: |