编写包含用户决策提示的 SpecFlow 场景
我是 SpecFlow 和 BDD 的新手,在编写需要用户做出选择的场景时遇到了障碍。基本上情况是这样的:
Scenario: Deleting a record
Given I am on the edit record page
And I click the delete button
Then I should see a prompt asking for confirmation
我不知道如何继续下去。这里有两种测试路径,一种是当用户对确认说“确定”时,另一种是当用户说“取消”时。
我想说“如果我点击确定”,然后是“那么记录应该被删除”,等等。但似乎应该以更好的方式分解它。
你会如何重新表述这个场景?
I'm new to SpecFlow and BDD and I've hit a roadblock in writing a scenario that requires a user to make a choice. Essentially here is the scenario:
Scenario: Deleting a record
Given I am on the edit record page
And I click the delete button
Then I should see a prompt asking for confirmation
I'm not sure how to proceed beyond this point. There are two paths to test here, one for when the user says "OK" to the confirmation, and one for when the user says "Cancel".
I want to say "And If I click OK" followed by "Then the record should be deleted", etc. But it seems like it should be broken up a better way.
How would you reword this scenario?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我建议在更高的层次上编写你的场景。在您的场景中避免使用按钮、单击和文本框,并尝试谈论用户想要完成的任务 - 您的系统的行为。然后,与页面的实际交互隐藏在步骤定义中。
所以在你的情况下,会是这样的;
假设我在记录页面上,
当我删除一条记录时
,那么我应该看到一条确认消息
,然后在 [When("I delete a record")] 的步骤定义中,您可以实现单击删除按钮和确定按钮“您确定吗”或删除记录所需的任何内容。
我希望这一点很清楚。写在我的手机上;)
I would recommend writing your scenarios on a higher level. Avoid buttons, clicks and textboxes in your scenarios and try to talk about what the user want to accomplish - the behaviour of your system. The actual interaction with the page is then hidden in the step definitions.
So in your case that will be something like;
Given I am on the record page
When I delete a record
Then I should see a confirmation message
In the step definition for [When("I delete a record")] you then implement the clicking on the delete button and the Ok-button for "are you sure" or whatever is needed to delete the record.
I hope this was clear. Wrote it on my phone ;)
这里实际上可能存在三种情况。第一个重点正如马库斯建议的那样:
但是确认对话框的行为是否也有场景?
和
There might actually be three scenarios here. The first one focusses as Marcus suggests:
But are there also scenarios for the behaviour of the confirmation dialog?
And