我需要测试当用户多次重复一组操作时触发的行为。我想最终得到一个看起来像这样的场景:
Scenario: Nice way
Given that I am on some screen
When I enter something into some text field
And I press the Continue button
And I go back
And I repeat the previous 2 steps 5 times
Then the application should crash
Run Code Online (Sandbox Code Playgroud)
而不是看起来像这样的场景:
Scenario: Annoying way
Given that I am on some screen
When I enter something into some text field
And I press the Continue button
And I go back
And I press the Continue button
And I go back
And I press the Continue button
And I go back
And I press the Continue button
And I go back
And I press the Continue button
And I go back
And I press the Continue button
And I go back
Then the application should crash
Run Code Online (Sandbox Code Playgroud)
有没有标准的方法来做到这一点,还是我必须自己实现?
如果您可以控制步骤定义代码,请尝试这样的步骤 -
And I press Continue button and go back 5 times
Run Code Online (Sandbox Code Playgroud)
使用变量捕获步骤定义中的次数,并在循环中调用现有函数的次数。