use of io.cucumber.core.backend.ObjectFactory in project cucumber-jvm by cucumber.
the class SpringFactoryTest method shouldNeverCreateNewApplicationBeanInstancesUsingMetaConfiguration.
@Test
void shouldNeverCreateNewApplicationBeanInstancesUsingMetaConfiguration() {
// Feature 1
final ObjectFactory factory1 = new SpringFactory();
factory1.addClass(BellyMetaStepDefinitions.class);
factory1.start();
final BellyBean o1 = factory1.getInstance(BellyMetaStepDefinitions.class).getBellyBean();
factory1.stop();
// Feature 2
final ObjectFactory factory2 = new SpringFactory();
factory2.addClass(BellyMetaStepDefinitions.class);
factory2.start();
final BellyBean o2 = factory2.getInstance(BellyMetaStepDefinitions.class).getBellyBean();
factory2.stop();
assertAll(() -> assertThat(o1, is(notNullValue())), () -> assertThat(o2, is(notNullValue())), () -> assertThat(o1, is(equalTo(o1))), () -> assertThat(o2, is(equalTo(o2))));
}
use of io.cucumber.core.backend.ObjectFactory in project cucumber-jvm by cucumber.
the class SpringFactoryTest method shouldFailIfClassWithAnnotationAnnotatedWithSpringComponentAnnotationsIsFound.
@Test
void shouldFailIfClassWithAnnotationAnnotatedWithSpringComponentAnnotationsIsFound() {
final ObjectFactory factory = new SpringFactory();
Executable testMethod = () -> factory.addClass(WithControllerAnnotation.class);
CucumberBackendException actualThrown = assertThrows(CucumberBackendException.class, testMethod);
assertThat(actualThrown.getMessage(), is(equalTo("Glue class io.cucumber.spring.componentannotation.WithControllerAnnotation was annotated with @Controller; marking it as a candidate for auto-detection by Spring. Glue classes are detected and registered by Cucumber. Auto-detection of glue classes by spring may lead to duplicate bean definitions. Please remove the @Controller annotation")));
}
use of io.cucumber.core.backend.ObjectFactory in project cucumber-jvm by cucumber.
the class SpringFactoryTest method shouldReuseStepDefsCreatedImplicitlyForAutowiring.
@Test
void shouldReuseStepDefsCreatedImplicitlyForAutowiring() {
final ObjectFactory factory1 = new SpringFactory();
factory1.addClass(WithSpringAnnotations.class);
factory1.addClass(OneStepDef.class);
factory1.addClass(ThirdStepDef.class);
factory1.addClass(AutowiresThirdStepDef.class);
factory1.start();
final OneStepDef o1 = factory1.getInstance(OneStepDef.class);
final AutowiresThirdStepDef o3 = factory1.getInstance(AutowiresThirdStepDef.class);
factory1.stop();
assertAll(() -> assertThat(o1.getThirdStepDef(), is(notNullValue())), () -> assertThat(o3.getThirdStepDef(), is(notNullValue())), () -> assertThat(o1.getThirdStepDef(), is(equalTo(o3.getThirdStepDef()))), () -> assertThat(o3.getThirdStepDef(), is(equalTo(o1.getThirdStepDef()))));
}
use of io.cucumber.core.backend.ObjectFactory in project cucumber-jvm by cucumber.
the class GuiceFactoryTest method factoryCanBeInstantiatedWithDefaultConstructor.
@Test
void factoryCanBeInstantiatedWithDefaultConstructor() {
ObjectFactory factory = new GuiceFactory();
assertThat(factory, notNullValue());
}
Aggregations