cancel
Showing results for 
Search instead for 
Did you mean: 

Where to store common logic like login

SOLVED
Camo
Occasional Contributor

Where to store common logic like login

I have a few features which test resources which needs to login. Every feature has its own steps class with concrete steps. But each of this features needs to make login, so I tried to make baseSteps which contains 

 

    @Given("Login")
    public void login()
    {
        new HomepagePage().login(conf.getString("login.email"), conf.getString("login.password"));
    }

 

But as I see Cucumber does not allow inheritance of classes with steps and hooks.

It throws me an error: Unable to start Cucumber
io.cucumber.java.InvalidMethodException: You're not allowed to extend classes that define Step Definitions or hooks. class steps.admin.CreateEditArticleSteps extends class steps.BaseSteps

 

What is the best practice to achieve this logic? I dont want to have login method in every steps class. 

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Where to store common logic like login

Hello,

 

Did you had the opportunity to take a look in the documentation? https://cucumber.io/docs/cucumber/state/

 

Based on your snippet, I assume you are using cucumber-jvm. Could DI help?

View solution in original post

2 REPLIES 2

Re: Where to store common logic like login

Hello,

 

Did you had the opportunity to take a look in the documentation? https://cucumber.io/docs/cucumber/state/

 

Based on your snippet, I assume you are using cucumber-jvm. Could DI help?

View solution in original post

Camo
Occasional Contributor

Re: Where to store common logic like login

No did not find it. But found a some mentions which say the login should be the part of each scenario. This is something opposite. Thanks.

New Here?
Join us and watch the welcome video:
Announcements