我应该在除assert
步骤之外的任何BDD步骤中使用then
吗?
我试图了解如何使用Specflow来描述“更改用户个人资料”。
SCENARIO I can change a user
Given I am at the roles page
And I can see a list of users
When I click a user's name
| field | value |
| User | John Doe |
And I change the user's name
| field | value |
| User | Jane Doe |
And I click the 'modify' button
Then I should the user updated in the list
我认为第二个给定步骤And I can see a list of users
应该在实现中有一个断言?
答案 0 :(得分:0)
我认为And I can see a list of users
不是有效的“给定”步骤。如果在某些情况下您可能位于角色页面而没有看到用户列表,那么无论何种情况导致您看到列表都应指定为“给定”步骤,但是如果您希望始终看到列表用户,那么它不需要是“给定”步骤。
也就是说,如果你应该总是看到用户列表,你应该有两个测试:
Given I am an admin
When I am at the roles page
Then I should see a list of users
Given I am an admin
And I am at the roles page
When I click a user's name
... etc.
或者,如果在某些情况下您可能看不到用户列表,那就是单独的“给定”:
Given I am an admin
And some users exist
When I am at the roles page
Then I should see a list of users
Given I am an admin
And some users exist
And I am at the roles page
When I click a user's name
... etc.
自第一次测试通过以来,在第二次测试中,您可以假设您看到了用户列表。
答案 1 :(得分:0)
请记住指定什么不是如何,并使用具体的例子。
场景:管理员可以编辑现有用户的个人资料详情
Given user profiles exist | Name | Age | | Andy | 21 | | Sarah| 22 | And Admin has started editing Andy's profile When 'Andy's profile is changed to - name:'Bob' age:'99' Then the Admin's summary of users includes | Name | Age| | Bob | 99 | | Sarah | 22 |