gpt4 book ai didi

java - Cucumber guice 迁移到版本 1.2.4

转载 作者:行者123 更新时间:2023-11-30 07:15:36 24 4
gpt4 key购买 nike

我想将 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 步:创建一个类:

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

第 2 步: 在 cucumber.properties 文件中:

guice.injector-source=test.MyjectorSource

关于java - Cucumber guice 迁移到版本 1.2.4,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38463146/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com