Stéphane GRILLON
Stéphane GRILLON

Reputation: 11864

cucumber guice migration to version 1.2.4

I want migrate cucumber.runtime.java.guice 1.1.1 to 1.2.4

In version 1.1.1 GuiceFactory take this value guiceModule=test.MyModule in src\test\resources\cucumber-guice.properties file but do not work in version 1.2.4.

This project is a good example (https://github.com/rapaul/cucumber-jvm-guice-examples) in version 1.1.1 but I need use 1.2.4 in my project.

public class MyModule implements Module {

    @Override
    public void configure(Binder binder) {
        System.out.println("MyModule configure");
        StepsInterceptor stepsInterceptor = new StepsInterceptor();
        binder.bindInterceptor(any(), annotatedWith(SpeedRegulator.class), stepsInterceptor);
    }

}

Please, how to use new version of GuiceFactory?

Upvotes: 1

Views: 141

Answers (1)

Stéphane GRILLON
Stéphane GRILLON

Reputation: 11864

I find the solution:

step 1: create a class:

public class MyjectorSource implements InjectorSource {
    @Override
    public Injector getInjector() {
        return Guice.createInjector(Stage.PRODUCTION, CucumberModules.SCENARIO, new MyModule());
    }
}

Step 2: in cucumber.properties file:

guice.injector-source=test.MyjectorSource

Upvotes: 1

Related Questions