continue running cucumber steps after a failure

21,187

It is not a good idea to continue executing steps after a step failure because a step failure can leave the World with an invariant violation. A better strategy is to increase the granularity of your scenarios. Instead of writing a single scenario with several "Then" statements, use a list of examples to separately test each postconditions. Sometimes a scenario outline and list of examples can consolidate similar stories. https://docs.cucumber.io/gherkin/reference/#scenario-outline

There is some discussion about adding a feature to tag certain steps to continue after failure. https://github.com/cucumber/cucumber/issues/79

Share:
21,187
Manish
Author by

Manish

Updated on December 18, 2020

Comments

  • Manish
    Manish over 3 years

    Is there any way to continue executing Cucumber Steps even when one of the steps fails. In my current setup when a step fails , cucumber skips remaining steps....I wonder if there is some way to twick cucumber runner setup..

    I could comment out failing steps but its not practical when you dont know which step will fail...If i could continue with remaining step i would know complete set of failing Tests in one shot....rather than going in cycle over cycle...

    Environment: Cucumber JVM , R , Java , Ibatis , Spring Framework, Maven

  • Ariejan
    Ariejan about 10 years
    "The only issue would be that, in the report, all the steps would look green but the test case looks failed." That's exactly why you don't want to do this.
  • pelican
    pelican over 7 years
    I see this is from years ago but if you can, could you please update the broken link?
  • switch201
    switch201 over 4 years
    "because a step failure can leave the World with an invariant violation". That assumption is true but not always the case. There are many instances where I need to a check a value and just because the value is incorrect that doesn't mean the rest of the scenario can not be run.