Friday, August 14, 2015

How to execute a Cucumber Scenario / Feature multiple times?

You can use several approaches:
  1. On operation system level: run command several times or write appropriate shell script.
  2. On Cucumber level. E.g. you have following feature file:
Feature: My great feature Scenario: My scenario Given My given step one When My when step two Then My then step three
You can force cucumber-jvm run it several times e.g. 3 by transforming "Scenario" to "Scenario outlines" and using "Examples":
Feature: My great feature
  Scenario **Outline**: My scenario
   Given My given step <number>
   When My when step two
   Then My then step three
Examples: to run this scenario several times
   |number|
   |one|
   |one|
   |one|
It looks some artificially, but works. I use this approach to gather statistics for complex tests dependent of a lot of conditions.

No comments:

Post a Comment