use of io.cucumber.core.backend.ObjectFactory in project cucumber-jvm by cucumber.
the class Issue1970 method issue1970.
@Test
public void issue1970() {
ObjectFactory factory = new SpringFactory();
// Add glue with Spring configuration
factory.addClass(GlueClass.class);
factory.start();
GlueClass instance = factory.getInstance(GlueClass.class);
String response = instance.service.get();
factory.stop();
factory.start();
GlueClass instance2 = factory.getInstance(GlueClass.class);
String response2 = instance2.service.get();
factory.stop();
assertNotEquals(response, response2);
}
use of io.cucumber.core.backend.ObjectFactory in project cucumber-jvm by cucumber.
the class SpringFactoryTest method shouldRespectContextHierarchyInStepDefs.
@Test
void shouldRespectContextHierarchyInStepDefs() {
final ObjectFactory factory = new SpringFactory();
factory.addClass(WithContextHierarchyAnnotation.class);
factory.start();
WithContextHierarchyAnnotation stepdef = factory.getInstance(WithContextHierarchyAnnotation.class);
factory.stop();
assertThat(stepdef, is(notNullValue()));
assertTrue(stepdef.isAutowired());
}
use of io.cucumber.core.backend.ObjectFactory in project cucumber-jvm by cucumber.
the class SpringFactoryTest method shouldNeverCreateNewApplicationBeanInstances.
@Test
void shouldNeverCreateNewApplicationBeanInstances() {
// Feature 1
final ObjectFactory factory1 = new SpringFactory();
factory1.addClass(BellyStepDefinitions.class);
factory1.start();
final BellyBean o1 = factory1.getInstance(BellyStepDefinitions.class).getBellyBean();
factory1.stop();
// Feature 2
final ObjectFactory factory2 = new SpringFactory();
factory2.addClass(BellyStepDefinitions.class);
factory2.start();
final BellyBean o2 = factory2.getInstance(BellyStepDefinitions.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 shouldFindStepDefsCreatedImplicitlyForAutowiring.
@Test
void shouldFindStepDefsCreatedImplicitlyForAutowiring() {
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 ThirdStepDef o2 = factory1.getInstance(ThirdStepDef.class);
factory1.stop();
assertAll(() -> assertThat(o1.getThirdStepDef(), is(notNullValue())), () -> assertThat(o2, is(notNullValue())), () -> assertThat(o1.getThirdStepDef(), is(equalTo(o2))), () -> assertThat(o2, is(equalTo(o1.getThirdStepDef()))));
}
use of io.cucumber.core.backend.ObjectFactory in project cucumber-jvm by cucumber.
the class SpringFactoryTest method shouldRespectDirtiesContextAnnotationsInStepDefs.
@Test
void shouldRespectDirtiesContextAnnotationsInStepDefs() {
final ObjectFactory factory = new SpringFactory();
factory.addClass(DirtiesContextBellyStepDefinitions.class);
// Scenario 1
factory.start();
final BellyBean o1 = factory.getInstance(DirtiesContextBellyStepDefinitions.class).getBellyBean();
factory.stop();
// Scenario 2
factory.start();
final BellyBean o2 = factory.getInstance(DirtiesContextBellyStepDefinitions.class).getBellyBean();
factory.stop();
assertAll(() -> assertThat(o1, is(notNullValue())), () -> assertThat(o2, is(notNullValue())), () -> assertThat(o1, is(not(equalTo(o2)))), () -> assertThat(o2, is(not(equalTo(o1)))));
}
Aggregations