Karl Krukow
Karl Krukow

Reputation: 11

cucumber accessing all steps in a scenario

I want to create a step definition that runs the current scenario several times in different contexts (different user languages).

Feature: Languages
  Scenario: Open main page
  Given I launch the app using languages "en" "da"
  When I ...
  Then I ...

I'd like to implement the "Given I launch the app using languages.." so that it initializes the application using english as the language, then runs all steps below "Given". Then it should restart the app, reinitialize using danish as the language and run the same steps.

In the step definition for Given I launch ..., is it possible to access, manipulate and run all the "future" steps in the scenario?

Upvotes: 1

Views: 336

Answers (1)

AlistairH
AlistairH

Reputation: 3229

You should use a scenario outline for this:

Feature: Languages
  Scenario Outline: Open main page
    Given I launch the app using language <lang>
    When I ...
    Then ...
    Examples:
    |lang|
    |"en"|
    |"da"|

Upvotes: 3

Related Questions