Search in sources :

Example 1 with BellyBean

use of cucumber.runtime.java.spring.beans.BellyBean in project cucumber-jvm by cucumber.

the class SpringFactoryTest method shouldRespectDirtiesContextAnnotationsInStepDefsUsingMetaConfiguration.

@Test
public void shouldRespectDirtiesContextAnnotationsInStepDefsUsingMetaConfiguration() {
    final ObjectFactory factory = new SpringFactory();
    factory.addClass(DirtiesContextBellyMetaStepDefs.class);
    // Scenario 1
    factory.start();
    final BellyBean o1 = factory.getInstance(DirtiesContextBellyMetaStepDefs.class).getBellyBean();
    factory.stop();
    // Scenario 2
    factory.start();
    final BellyBean o2 = factory.getInstance(DirtiesContextBellyMetaStepDefs.class).getBellyBean();
    factory.stop();
    assertNotNull(o1);
    assertNotNull(o2);
    assertNotSame(o1, o2);
}
Also used : ObjectFactory(cucumber.api.java.ObjectFactory) DirtiesContextBellyMetaStepDefs(cucumber.runtime.java.spring.metaconfig.dirties.DirtiesContextBellyMetaStepDefs) BellyBean(cucumber.runtime.java.spring.beans.BellyBean) Test(org.junit.Test)

Example 2 with BellyBean

use of cucumber.runtime.java.spring.beans.BellyBean in project cucumber-jvm by cucumber.

the class SpringFactoryTest method shouldRespectDirtiesContextAnnotationsInStepDefs.

@Test
public void shouldRespectDirtiesContextAnnotationsInStepDefs() {
    final ObjectFactory factory = new SpringFactory();
    factory.addClass(DirtiesContextBellyStepDefs.class);
    // Scenario 1
    factory.start();
    final BellyBean o1 = factory.getInstance(DirtiesContextBellyStepDefs.class).getBellyBean();
    factory.stop();
    // Scenario 2
    factory.start();
    final BellyBean o2 = factory.getInstance(DirtiesContextBellyStepDefs.class).getBellyBean();
    factory.stop();
    assertNotNull(o1);
    assertNotNull(o2);
    assertNotSame(o1, o2);
}
Also used : DirtiesContextBellyStepDefs(cucumber.runtime.java.spring.dirtiescontextconfig.DirtiesContextBellyStepDefs) ObjectFactory(cucumber.api.java.ObjectFactory) BellyBean(cucumber.runtime.java.spring.beans.BellyBean) Test(org.junit.Test)

Example 3 with BellyBean

use of cucumber.runtime.java.spring.beans.BellyBean in project cucumber-jvm by cucumber.

the class SpringFactoryTest method shouldNeverCreateNewApplicationBeanInstancesUsingMetaConfiguration.

@Test
public void shouldNeverCreateNewApplicationBeanInstancesUsingMetaConfiguration() {
    // Feature 1
    final ObjectFactory factory1 = new SpringFactory();
    factory1.addClass(BellyMetaStepdefs.class);
    factory1.start();
    final BellyBean o1 = factory1.getInstance(BellyMetaStepdefs.class).getBellyBean();
    factory1.stop();
    // Feature 2
    final ObjectFactory factory2 = new SpringFactory();
    factory2.addClass(BellyMetaStepdefs.class);
    factory2.start();
    final BellyBean o2 = factory2.getInstance(BellyMetaStepdefs.class).getBellyBean();
    factory2.stop();
    assertNotNull(o1);
    assertNotNull(o2);
    assertSame(o1, o2);
}
Also used : ObjectFactory(cucumber.api.java.ObjectFactory) BellyBean(cucumber.runtime.java.spring.beans.BellyBean) BellyMetaStepdefs(cucumber.runtime.java.spring.metaconfig.general.BellyMetaStepdefs) Test(org.junit.Test)

Example 4 with BellyBean

use of cucumber.runtime.java.spring.beans.BellyBean 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)

Aggregations

ObjectFactory (cucumber.api.java.ObjectFactory)4 BellyBean (cucumber.runtime.java.spring.beans.BellyBean)4 Test (org.junit.Test)4 BellyStepdefs (cucumber.runtime.java.spring.contextconfig.BellyStepdefs)1 DirtiesContextBellyStepDefs (cucumber.runtime.java.spring.dirtiescontextconfig.DirtiesContextBellyStepDefs)1 DirtiesContextBellyMetaStepDefs (cucumber.runtime.java.spring.metaconfig.dirties.DirtiesContextBellyMetaStepDefs)1 BellyMetaStepdefs (cucumber.runtime.java.spring.metaconfig.general.BellyMetaStepdefs)1