Search in sources :

Example 1 with GlueScopedComponent

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

the class SpringFactoryTest method shouldThrowWhenGlueScopedSpringBeanAreUsedOutsideLifecycle.

@Test
void shouldThrowWhenGlueScopedSpringBeanAreUsedOutsideLifecycle() {
    final ObjectFactory factory = new SpringFactory();
    factory.addClass(WithSpringAnnotations.class);
    factory.start();
    final Belly belly = factory.getInstance(Belly.class);
    final GlueScopedComponent glue = factory.getInstance(GlueScopedComponent.class);
    factory.stop();
    assertDoesNotThrow(belly::getInstanceId);
    assertThrows(BeanCreationException.class, glue::getInstanceId);
}
Also used : GlueScopedComponent(io.cucumber.spring.beans.GlueScopedComponent) ObjectFactory(io.cucumber.core.backend.ObjectFactory) Belly(io.cucumber.spring.beans.Belly) Test(org.junit.jupiter.api.Test)

Aggregations

ObjectFactory (io.cucumber.core.backend.ObjectFactory)1 Belly (io.cucumber.spring.beans.Belly)1 GlueScopedComponent (io.cucumber.spring.beans.GlueScopedComponent)1 Test (org.junit.jupiter.api.Test)1