黄瓜 guice 迁移到版本 1.2.4
cucumber guice migration to version 1.2.4
我想迁移 cucumber.runtime.java.guice 1.1.1 到 1.2.4
在版本 1.1.1 中,GuiceFactory 在 src\test\resources\cucumber-guice.properties
文件中采用此值 guiceModule=test.MyModule
,但在版本 1.2.4 中不起作用。
这个项目是 1.1.1 版的一个很好的例子 (https://github.com/rapaul/cucumber-jvm-guice-examples),但我需要在我的项目中使用 1.2.4。
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);
}
}
请问新版GuiceFactory如何使用?
我找到了解决方案:
步骤 1: 创建 class:
public class MyjectorSource implements InjectorSource {
@Override
public Injector getInjector() {
return Guice.createInjector(Stage.PRODUCTION, CucumberModules.SCENARIO, new MyModule());
}
}
第 2 步: 在 cucumber.properties 文件中:
guice.injector-来源=test.MyjectorSource
我想迁移 cucumber.runtime.java.guice 1.1.1 到 1.2.4
在版本 1.1.1 中,GuiceFactory 在 src\test\resources\cucumber-guice.properties
文件中采用此值 guiceModule=test.MyModule
,但在版本 1.2.4 中不起作用。
这个项目是 1.1.1 版的一个很好的例子 (https://github.com/rapaul/cucumber-jvm-guice-examples),但我需要在我的项目中使用 1.2.4。
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);
}
}
请问新版GuiceFactory如何使用?
我找到了解决方案:
步骤 1: 创建 class:
public class MyjectorSource implements InjectorSource {
@Override
public Injector getInjector() {
return Guice.createInjector(Stage.PRODUCTION, CucumberModules.SCENARIO, new MyModule());
}
}
第 2 步: 在 cucumber.properties 文件中:
guice.injector-来源=test.MyjectorSource