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.
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?