cucumber/gherkin

Consider adding `After` as keyword to the Gherkin syntax

JayGray opened this issue · 3 comments

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

Even though Cucumber itself provides hooks to clean up any mess created by every test, I'm missing a simple solution
to tidy up some leftovers of a special test case.

99% percent of our test behave in a good manner and don't leave anything behind or the app in question in a bad shape
however, there are a few tests that require a cleaning crew.

ATM we just add a And/Then step to the end of the scenario

✨ What's your proposed solution?

Adding an AFTER step to the Gherkin keywords that behaves as Background just after a scenario is finished.

⛏ Have you considered any alternatives or workarounds?

Yes, using the after* hooks with much extra logic to determine if the hook is even needed to execute.

📚 Any additional context?

Dunno yet, let me know if you need more.

PS. Adding the keyword is not the end of the story as all the different language implementations of parsing and executing Gherkin need to support it as well, but I thought this is the best place to start.

Thx

+1

Yes, using the after* hooks with much extra logic to determine if the hook is even needed to execute.

What extra logic is required if you apply tags to the scenarios and use conditional "After" hooks as per https://cucumber.io/docs/cucumber/api/?lang=java#conditional-hooks ?

Cleanup of a scenario should be invisible and not documented in the scenario proper. So like @ehuelsmann said above. You should be using standard hooks for tidy up. So a standard After hook should suffice, with either tagged or conditional logic