use of org.jbehave.core.steps.AbstractStepsFactory in project jbehave-core by jbehave.
the class GuiceStepsFactoryBehaviour method assertThatStepsWithMissingDependenciesCannotBeCreated.
@Test(expected = CreationException.class)
public void assertThatStepsWithMissingDependenciesCannotBeCreated() throws NoSuchFieldException, IllegalAccessException {
Injector parent = Guice.createInjector(new AbstractModule() {
@Override
protected void configure() {
bind(FooStepsWithDependency.class);
}
});
AbstractStepsFactory factory = new GuiceStepsFactory(new MostUsefulConfiguration(), parent);
// When
factory.createCandidateSteps();
// Then ... expected exception is thrown
}
use of org.jbehave.core.steps.AbstractStepsFactory in project jbehave-core by jbehave.
the class GuiceStepsFactoryBehaviour method assertThatStepsCanBeCreated.
@Test
public void assertThatStepsCanBeCreated() throws NoSuchFieldException, IllegalAccessException {
// Given
Injector parent = Guice.createInjector(new AbstractModule() {
@Override
protected void configure() {
bind(FooSteps.class).in(Scopes.SINGLETON);
}
});
AbstractStepsFactory factory = new GuiceStepsFactory(new MostUsefulConfiguration(), parent);
// When
List<CandidateSteps> steps = factory.createCandidateSteps();
// Then
assertFooStepsFound(steps);
}
use of org.jbehave.core.steps.AbstractStepsFactory in project jbehave-core by jbehave.
the class GuiceStepsFactoryBehaviour method assertThatStepsWithStepsWithDependencyCanBeCreated.
@Test
public void assertThatStepsWithStepsWithDependencyCanBeCreated() throws NoSuchFieldException, IllegalAccessException {
Injector parent = Guice.createInjector(new AbstractModule() {
@Override
protected void configure() {
bind(Integer.class).toInstance(42);
bind(FooStepsWithDependency.class).in(Scopes.SINGLETON);
}
});
// When
AbstractStepsFactory factory = new GuiceStepsFactory(new MostUsefulConfiguration(), parent);
List<CandidateSteps> steps = factory.createCandidateSteps();
// Then
assertFooStepsFound(steps);
assertThat((int) ((FooStepsWithDependency) stepsInstance(steps.get(0))).integer, equalTo(42));
}
Aggregations