Forum Discussion

Camo's avatar
Camo
Occasional Contributor
4 years ago

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. 

    • Camo's avatar
      Camo
      Occasional Contributor

      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.