I am trying to use DI in my step definitions. I have a module,
public class MyModule extends AbstractModule
{
private final static MyInterface INSTANCE = new MyInterfaceImpl();
@Override
protected void configure()
{
bind(MyInterface.class).toInstance(INSTANCE);
}
}
and want to inject this instance in the constructor of the step definitions.
public class MyStepDefs
{
private final MyInterface instance;
@Inject
public MyStepDefs(MyInterface instance)
{
this.instance = instance
}
}
I think I need to configure the GuiceFactory using a cucumber-guice.properties file but I don't really know what this is? At the moment the error I get is,
java.lang.NoClassDefFoundError: javax/inject/Singleton
at cucumber.runtime.java.guice.GuiceFactory$CucumberModule.configure(GuiceFactory.java:86)
Also should I be using a Provider for constructor injection?