我使用Cucumber
与Guice
作为DI。 我遇到以下问题: 我有一个步骤即黄瓜与Guice - 多个guice注射器
class MyStep() {
@Inject
private MyService myService;
@Given("Some acction happen")
public void sthHappen() {
myService.doSth();
}
}
而且我有这个类来运行它JUnit
测试
@RunWith(Cucumber.class)
@CucumberOptions(...)
public class MyTest {
}
有一个
class MyModule extends AbstractModule {
@Override
protected void configure() {
bind(MyService.class).to(MyFirstService.class);
}
}
这是我的使用MyInjectorSource
我定义了cucumber.properties我定义了guice.injector-source=MyInjectorSource;
还有一个带有场景的功能文件。 一切都在为现在工作。
而且没有我想同他的MyService实施MyStep步(当然我不惯于重复MyStep的代码) 我定义与新方案的一个新特性文件,新的测试类
@RunWith(Cucumber.class)
@CucumberOptions(...)
public class MyOtherTest {
}
现在我试图创建另一个InjectorSource
但我无法对其进行配置。
如果你所放置的“@Inject”标注在“@Before”挂钩?您可以根据标签创建不同的'@Before'钩子,例如'@ Before'('@ tag1')和'@Before'('@ tag2')。每个人都有不同的'@Inject'定义。 – MikeJRamsey56
如何在评论中转义'@'? – MikeJRamsey56