Search in sources :

Example 1 with BellyBean

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

the class SpringFactoryTest method shouldRespectDirtiesContextAnnotationsInStepDefsUsingMetaConfiguration.

@Test
void shouldRespectDirtiesContextAnnotationsInStepDefsUsingMetaConfiguration() {
    final ObjectFactory factory = new SpringFactory();
    factory.addClass(DirtiesContextBellyMetaStepDefinitions.class);
    // Scenario 1
    factory.start();
    final BellyBean o1 = factory.getInstance(DirtiesContextBellyMetaStepDefinitions.class).getBellyBean();
    factory.stop();
    // Scenario 2
    factory.start();
    final BellyBean o2 = factory.getInstance(DirtiesContextBellyMetaStepDefinitions.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)))));
}
Also used : ObjectFactory(io.cucumber.core.backend.ObjectFactory) BellyBean(io.cucumber.spring.beans.BellyBean) DirtiesContextBellyMetaStepDefinitions(io.cucumber.spring.metaconfig.dirties.DirtiesContextBellyMetaStepDefinitions) Test(org.junit.jupiter.api.Test)

Example 2 with BellyBean

use of io.cucumber.spring.beans.BellyBean 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))));
}
Also used : DirtiesContextBellyStepDefinitions(io.cucumber.spring.dirtiescontextconfig.DirtiesContextBellyStepDefinitions) BellyStepDefinitions(io.cucumber.spring.contextconfig.BellyStepDefinitions) ObjectFactory(io.cucumber.core.backend.ObjectFactory) BellyBean(io.cucumber.spring.beans.BellyBean) Test(org.junit.jupiter.api.Test)

Example 3 with BellyBean

use of io.cucumber.spring.beans.BellyBean 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)))));
}
Also used : ObjectFactory(io.cucumber.core.backend.ObjectFactory) BellyBean(io.cucumber.spring.beans.BellyBean) DirtiesContextBellyStepDefinitions(io.cucumber.spring.dirtiescontextconfig.DirtiesContextBellyStepDefinitions) Test(org.junit.jupiter.api.Test)

Example 4 with BellyBean

use of io.cucumber.spring.beans.BellyBean 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))));
}
Also used : BellyMetaStepDefinitions(io.cucumber.spring.metaconfig.general.BellyMetaStepDefinitions) DirtiesContextBellyMetaStepDefinitions(io.cucumber.spring.metaconfig.dirties.DirtiesContextBellyMetaStepDefinitions) ObjectFactory(io.cucumber.core.backend.ObjectFactory) BellyBean(io.cucumber.spring.beans.BellyBean) Test(org.junit.jupiter.api.Test)

Aggregations

ObjectFactory (io.cucumber.core.backend.ObjectFactory)4 BellyBean (io.cucumber.spring.beans.BellyBean)4 Test (org.junit.jupiter.api.Test)4 DirtiesContextBellyStepDefinitions (io.cucumber.spring.dirtiescontextconfig.DirtiesContextBellyStepDefinitions)2 DirtiesContextBellyMetaStepDefinitions (io.cucumber.spring.metaconfig.dirties.DirtiesContextBellyMetaStepDefinitions)2 BellyStepDefinitions (io.cucumber.spring.contextconfig.BellyStepDefinitions)1 BellyMetaStepDefinitions (io.cucumber.spring.metaconfig.general.BellyMetaStepDefinitions)1