cucumber/gherkin

Can I decide whether the following steps should continue to execute based on the result of the previous step execution

lynnk1ng37 opened this issue · 1 comments

🤔 What's the problem you're trying to solve?

As a step to create data by a way, so if this way failed, I can decide to execute the follow steps to create data by second way, just because second way has some step and DataTable to config, so I can't use try catch on script, And I want to know anyway like try catch on step define?

✨ What's your proposed solution?

eg:
Scenario: Create Create Data
Given Create data by A
Given Create data by B_step1
Given Create data by B_step2
| | | |
| | | |
Given Create data by B_step3
| | | |
| | | |
Given Create data by B_step4

to

Scenario: Create Create Data
Try Create data by A
Catch Create data by B_step1
Catch Create data by B_step2
| | | |
| | | |
Catch Create data by B_step3
| | | |
| | | |
Catch Create data by B_step4

⛏ Have you considered any alternatives or workarounds?

📚 Any additional context?


This text was originally generated from a template, then edited by hand. You can modify the template here.

You can store the information about the success or failure to create something in the context of your step definition. Assuming you're using Java, if you have to share state between multiple step definitions you can use DI. For example:

https://github.com/cucumber/cucumber-jvm/tree/main/cucumber-picocontainer

This is the issue tracker of an Open Source project, this not a good place to ask for help. You may be better of on Stackoverflow.