I need to test behaviour that triggers when a user repeats a set of actions many times. I would like to end up with a scenario that looks something like this:
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
Rather than a scenario that looks like this:
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
Is there a standard way of doing this or do I have to implement it myself?
If you have control over the step definition code try a step like this -
And I press Continue button and go back 5 times
Capture the number of times in the step definition with a variable and call existing functions in a loop for the number of times.
It can be captured by something like:
@And("^I press Continue button and go back (//d+) times")
public void iPressContinueButtonAndGoBackNTimes(int n){
//enter code here
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With