I'm having a scenario which consists of around 500 steps.

About 490 steps out of the it are preconditions and steps that needs to be done, in order to come to a state where the actual acceptance (last 10 steps) can be done.

Is it really bad to have a large number of steps inside a single scenario. Is there a better approach where I can keep the original scenario bit clean and separate the preconditions.

  • 1
    Welcome to SQA. Having so many steps as preconditions seems like a nightmare to me. It depends on a situation, but think about how it can be simplified, because I assume that maintenance of such a scenario is time-consuming and requires so much past knowledge that e.g. new members of the team might not have. – pavelsaman Feb 8 '20 at 10:24

Just found out a tailor made solution for these kind of situations, from JBehave documentation.

"To help the user better manager more complex scenarios, JBehave allow the specification of entire stories as a pre-requisite for another story or scenario."




Even though the question is with JBehave, I think cucumber provides better documentation and will help you understand Gherkins better.

To summaries:

Your scenarios should describe the intended behaviour of the system, not the implementation. In other words, it should describe what, not how.

so instead of :

open browser
provide password
provide username
click login
user logins
he clicks the first item


user logins to portal
Adds item to cart
Checkouts and makes the payment

The actual implementation is hidden in the step definition. The user logins to portal actually reuses the functions to enter password ,click login etc , in the step definition.

Hide the implementation details in step definition and in feature file use only the process.

In your case add step like ,

user completes the prerequeiste tasks

add use it to wrap the actual 490 steps inside step-definition:

Running step before each story:

If you want to run this step before each story, then use before (if using jbehave syntax)

else use Background (If using Gherkin syntax)

Read more at:



  • It's not easy to implement more high level steps like you've mentioned, when the low level steps are heavily parametrized (etc : tabular parameters). – Aki T Feb 8 '20 at 12:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.