Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

153
Views
cucumber stop execution based on Examples parameter

Is it possible to stop running steps after a condition is met? For a web app with multiple pages, I have scenarios that check all pages, and some stop in the middle.

I would like to use the same feature file and not duplicate the scenario outline, currently, the feature looks like this:

Scenario Outline: TC__<tcNr>__<endScenarioPage>

    # dataPrep step
    Given step for data prep <params1> <params2>

    # page_1
    Given step 1 <params1>
    Given step 2 <params2>

    # page_2
    Then step 1 <params3>
    Then step 2 <params4> <endScenarioPage>

    # page_3
    Then step 1 <params5> 
    Then step 2 <params6>

    # page_4
    Then step 1 <params7>
    Then step 2 <params8>

    @set1
    Examples:
        | tcNr    | params1 | params2 | endScenarioPage |
        | "SCN01" | " ..."  | " ..."  | "page2"         |
        | "SCN02" | " ..."  | " ..."  | "page4"         |
        | "SCN03" | " ..."  | " ..."  | "page2"         |

    @set2
    Examples:
        | tcNr    | params1 | params2 | endScenarioPage |
        | "SCN01" | " ..."  | " ..."  | "page2"         |
        | "SCN02" | " ..."  | " ..."  | "page2"         |
        | "SCN03" | " ..."  | " ..."  | "page4"         |

so for scenarios "SCN01" and "SCN03" from @set1 tests should be stopped on page2.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Scenario Outlines are just a complicated way of writing several individual scenarios in one block of feature code. You would make things much simpler and clearer by not using on outline and just writing individual scenarios. Then your problem of stopping would just disappear, as that scenario would just not have that step

Scenario: 4 page example
  Given x
  Then 1
  And 2
  And 3
  And 4

Scenario: 2 page example
  Given y
  Then 1
  And 2

Its much better to write many simple scenarios (even if they have lots of repitition than one complex scenario outline (like you have in your question).

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!