Search in sources :

Example 11 with ObjectFactory

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);
}
Also used : ObjectFactory(cucumber.api.java.ObjectFactory) Test(org.junit.Test)

Example 12 with ObjectFactory

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);
}
Also used : ObjectFactory(cucumber.api.java.ObjectFactory) Test(org.junit.Test)

Example 13 with ObjectFactory

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);
}
Also used : ObjectFactory(cucumber.api.java.ObjectFactory) BellyStepdefs(cucumber.runtime.java.spring.contextconfig.BellyStepdefs) BellyBean(cucumber.runtime.java.spring.beans.BellyBean) Test(org.junit.Test)

Example 14 with ObjectFactory

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);
}
Also used : ObjectFactory(cucumber.api.java.ObjectFactory) Test(org.junit.Test)

Example 15 with ObjectFactory

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());
}
Also used : OneStepDef(cucumber.runtime.java.spring.commonglue.OneStepDef) ObjectFactory(cucumber.api.java.ObjectFactory) AutowiresThirdStepDef(cucumber.runtime.java.spring.commonglue.AutowiresThirdStepDef) Test(org.junit.Test)

Aggregations

ObjectFactory (cucumber.api.java.ObjectFactory)26 Test (org.junit.Test)24 BellyBean (cucumber.runtime.java.spring.beans.BellyBean)4 Backend (cucumber.runtime.Backend)2 CucumberException (cucumber.runtime.CucumberException)2 ResourceLoader (cucumber.runtime.io.ResourceLoader)2 JavaBackend (cucumber.runtime.java.JavaBackend)2 AutowiresPlatformTransactionManager (cucumber.runtime.java.spring.commonglue.AutowiresPlatformTransactionManager)2 AutowiresThirdStepDef (cucumber.runtime.java.spring.commonglue.AutowiresThirdStepDef)2 OneStepDef (cucumber.runtime.java.spring.commonglue.OneStepDef)2 BellyStepdefs (cucumber.runtime.java.spring.contextconfig.BellyStepdefs)2 WithSpringAnnotations (cucumber.runtime.java.spring.contextconfig.WithSpringAnnotations)2 OsgiClassFinder (cucumber.java.runtime.osgi.OsgiClassFinder)1 PaxExamObjectFactory (cucumber.java.runtime.osgi.PaxExamObjectFactory)1 ClassFinder (cucumber.runtime.ClassFinder)1 Glue (cucumber.runtime.Glue)1 NoInstancesException (cucumber.runtime.NoInstancesException)1 Reflections (cucumber.runtime.Reflections)1 Runtime (cucumber.runtime.Runtime)1 RuntimeOptions (cucumber.runtime.RuntimeOptions)1