I have a class created for step definitions which uses @Steps annotations from (net.thucydides.core.annotations.Steps) for injecting objects. It did work locally but when I ran it through java -jar it won't be able to initialize objects annotated with @Steps.
public class AutomationRunner {
public static void main(String[] args) throws Throwable {
JUnitCore.main(CucumberTestSuite.class.getName());
}
}
@RunWith(CucumberWithSerenity.class)
@CucumberOptions(
plugin = {"pretty"},
snippets = CucumberOptions.SnippetType.CAMELCASE,
features = "classpath:features",
tags = "@sometag",
glue = "com.package.stepdefinitions"
)
public class CucumberTestSuite {
}
public class Hooks {
// auto injected by serenity
private EnvironmentVariables environmentVariables;
@Steps(shared = true)
CommonUtilities commonUtilities;
@Before()
public void before() {
commonUtilities.someFunc(); // here getting nullpointer
}
}
I was able to generate jar file using maven-assembly-plugin to include all files and it executed tests as well but it failed at injecting objects using @steps in stepdefinations.