2

I am using Serenity with Cucumber to write automated web tests, I could not find in docummentation a way to ignore next tests when one fails.

Currently, if a step fails to run, next steps in the same SCENARIO are ignored, but next scenarios in the feature are executed.

I want that when a test fail, skip all next steps and scenarios.

Rogger Fernandes
  • 805
  • 4
  • 14
  • 28

2 Answers2

3

That isn't supported in Serenity or in BDD tools in general. Scenarios are intended to be independent examples of acceptance criteria or business rules, not steps in a larger test

John Smart
  • 969
  • 1
  • 5
  • 5
  • But what if the end-to-end test is so long, complex & time-consuming? In this case, testers/QAs will try to break the test into multiple tests/scenarios in which the initial query makes sense! – Bhala T R Apr 17 '23 at 10:27
0

To elaborate on what John Smart has said:

Each scenario should be able to pass without having to rely on the scenarios that have been run before it.

What's more: internet connection is known to be temperamental on occasion. If one of your scenarios fails because the Internet dropped out while waiting for a page to load, you don't want to have all the scenarios after that (that could be unaffected by the first failure) to be skipped.

In short:

Making your scenarios independent reduces brittleness of your automation suite.

Skipping scenarios if one fails is bad practice (especially for web applications), due to the fact that internet connection is not a constant that you can rely on.

KyleFairns
  • 2,947
  • 1
  • 15
  • 35
  • 2
    Sorry to wake up the thread, but this argument, although being correct, is incomplete, and thus is not enough to reject the practice. You only speak about temporary failures, but there are failures which are definitive: if you stored a wrong password for your connections, all your tests will fail. There is no point in continuing the tests. Especially if we speak about acceptance tests which tends to be heavier to execute than unit tests. Surely, skip tests after a failure, whatever it is, may be not the right way to go. But skipping tests after a specific kind of failure is relevant. – Matthieu Nov 07 '19 at 09:23
  • @Matthieu the issue with putting anything in place to make the rest of the tests fall over is that it may simply be a flaky test, and we should write tests with that in mind. It may be the wrong password for the connections, but if you're relying on that you could check that in your beforeall hook (as a health check) - putting that in at test level isn't the best option that you have in that scenario – KyleFairns Nov 07 '19 at 10:12