在Cucumber Gherkin中的同一场景中运行两个用户故事



我试图创建一个场景,让两个用户访问应用程序,这样我就可以在一个用户的购物车上(或多或少(模拟一个售罄的产品。

例如

Given user1 access website
Then user1 add a product to the cart

这里是user2(不太确定我是否应该使用另一个Given或And,这里的重点是打开另一个窗口,并保持user1的窗口保持不变(

Given user2 access website
Then user2 add a product to the cart
And user2 complete purchase(关闭用户2的窗口(

在这里,用户1将尝试完成购买(返回到用户1窗口(

Then user1 tries to finalize the purchase and gets a warning that product is no longer available

这更多的是一个想法,而不是实际的流程,但这里的要点是要有这个"流程";"冲突";空库存。我希望用户1能够将产品添加到购物车中,以便稍后显示该产品不再可用的警告。所以,我不能让场景从一个空库存开始,因为那样用户1甚至看不到要测试的产品

我建议使用以下线性方法。我假设有可能在不同选项卡的中的一个浏览器上登录2个用户

Given user1 access website
When user1 add a product to the cart
And I open 2nd chrome tab
And user2 access website on 2nd tab
And user2 add a product to the cart
And user2 complete purchase
And I close 2nd chrome tab
And I refresh session on 1st tab
Then user1 can not complete purchase and and see 'product no longer available' warn

我建议使用读者友好的定义,并使用When子句强调导致预期结果的操作

Given One item of "ShortProduct" is available 
And the following users are registered
| User Name      |
| James Luckless |
| John  Lucky    |
And "James Luckless" added a "ShortProduct" to the cart
And "John  Lucky" added a "ShortProduct" to the cart
And "John  Lucky" completed the purchase
When "James Luckless" attempts to finalize the purchase 
Then "James Luckless" gets a warning that "ShortProduct" is no longer available 

最新更新