use of cucumber.api.java.ObjectFactory in project cucumber-jvm by cucumber.
the class OpenEJBObjectFactoryTest method shouldGiveUsNewInstancesForEachScenario.
@Test
public void shouldGiveUsNewInstancesForEachScenario() {
ObjectFactory factory = new OpenEJBObjectFactory();
factory.addClass(BellyStepdefs.class);
// Scenario 1
factory.start();
BellyStepdefs o1 = factory.getInstance(BellyStepdefs.class);
factory.stop();
// Scenario 2
factory.start();
BellyStepdefs o2 = factory.getInstance(BellyStepdefs.class);
factory.stop();
assertNotNull(o1);
assertNotSame(o1, o2);
}
use of cucumber.api.java.ObjectFactory in project cucumber-jvm by cucumber.
the class JavaObjectFactoryTest method shouldGiveUsNewInstancesForEachScenario.
@Test
public void shouldGiveUsNewInstancesForEachScenario() {
ObjectFactory factory = new DefaultJavaObjectFactory();
factory.addClass(SteDef.class);
// Scenario 1
factory.start();
SteDef o1 = factory.getInstance(SteDef.class);
factory.stop();
// Scenario 2
factory.start();
SteDef o2 = factory.getInstance(SteDef.class);
factory.stop();
assertNotNull(o1);
assertNotSame(o1, o2);
}
use of cucumber.api.java.ObjectFactory in project cucumber-jvm by cucumber.
the class SpringFactoryTest method shouldNeverCreateNewApplicationBeanInstances.
@Test
public void shouldNeverCreateNewApplicationBeanInstances() {
// Feature 1
final ObjectFactory factory1 = new SpringFactory();
factory1.addClass(BellyStepdefs.class);
factory1.start();
final BellyBean o1 = factory1.getInstance(BellyStepdefs.class).getBellyBean();
factory1.stop();
// Feature 2
final ObjectFactory factory2 = new SpringFactory();
factory2.addClass(BellyStepdefs.class);
factory2.start();
final BellyBean o2 = factory2.getInstance(BellyStepdefs.class).getBellyBean();
factory2.stop();
assertNotNull(o1);
assertNotNull(o2);
assertSame(o1, o2);
}
use of cucumber.api.java.ObjectFactory in project cucumber-jvm by cucumber.
the class SpringFactoryTest method shouldFailIfClassesWithDifferentSpringAnnotationsAreFound.
@Test(expected = CucumberException.class)
public void shouldFailIfClassesWithDifferentSpringAnnotationsAreFound() {
final ObjectFactory factory = new SpringFactory();
factory.addClass(WithContextHierarchyAnnotation.class);
factory.addClass(WithDifferentContextHierarchyAnnotation.class);
}
use of cucumber.api.java.ObjectFactory in project cucumber-jvm by cucumber.
the class SpringFactoryTest method shouldReuseStepDefsCreatedImplicitlyForAutowiring.
@Test
public 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();
assertNotNull(o1.getThirdStepDef());
assertNotNull(o3.getThirdStepDef());
assertSame(o1.getThirdStepDef(), o3.getThirdStepDef());
}
Aggregations