Reputation: 21
I'm writing test using Java, Intellij, Selenium + Cucubmer. I have a simple test scenario:
Scenario: Add X random products to the shopping cart
Given I choose a random product from a list
When I add random quantity of the product to the shopping cart
Then I see that number of products in the cart was updated
After last step I should go to first step and repeat all process X times. I don't know how to achieve it within one scenario without copying steps. Is it possible to run steps 1-3 in a loop?
Upvotes: 1
Views: 8387
Reputation: 11
Try using following
Scenario: Add X random products to the shopping cart
* configure retry = { count: <no-of-counts>, interval: <interval-between-each-retry-in-ms>}
Given I choose a random product from a list
And retry until <your-conditions>
When I add random quantity of the product to the shopping cart
Then I see that number of products in the cart was updated
Example:
Scenario: Add X random products to the shopping cart
* configure retry = { count: X, interval: 0}
Given I choose a random product from a list
And retry until true
When I add random quantity of the product to the shopping cart
Then I see that number of products in the cart was updated
Here i have used count X as i have to add X random products and don't want to wait between them so the interval is 0 ms. I have also made the condition to be always true since i want to run for X without any conditions. You can write some condition like X==Y or X>Y or any other expression which results in a boolean value.
Upvotes: 0
Reputation: 9058
You can convert this into a dummy ScenarioOutline
like below and extend the examples table to whatever times you want.
ScenarioOutline: Add X random products to the shopping cart
Given I choose a random product from a list
When I add random quantity of the product to the shopping cart
Then I see that number of products in the cart was updated
Examples:
| id |
| 1 |
| 2 |
| 3 |
Another way is to hack the runner code but this will only work for a single scenario you want repeated. How to execute same cucumber feature or scenario n times?
Upvotes: 1