Search in sources :

Example 1 with OneStepDef

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

Example 2 with OneStepDef

use of cucumber.runtime.java.spring.commonglue.OneStepDef in project cucumber-jvm by cucumber.

the class SpringFactoryTest method shouldFindStepDefsCreatedImplicitlyForAutowiring.

@Test
public void shouldFindStepDefsCreatedImplicitlyForAutowiring() {
    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 ThirdStepDef o2 = factory1.getInstance(ThirdStepDef.class);
    factory1.stop();
    assertNotNull(o1.getThirdStepDef());
    assertNotNull(o2);
    assertSame(o1.getThirdStepDef(), o2);
}
Also used : OneStepDef(cucumber.runtime.java.spring.commonglue.OneStepDef) ObjectFactory(cucumber.api.java.ObjectFactory) ThirdStepDef(cucumber.runtime.java.spring.commonglue.ThirdStepDef) AutowiresThirdStepDef(cucumber.runtime.java.spring.commonglue.AutowiresThirdStepDef) Test(org.junit.Test)

Aggregations

ObjectFactory (cucumber.api.java.ObjectFactory)2 AutowiresThirdStepDef (cucumber.runtime.java.spring.commonglue.AutowiresThirdStepDef)2 OneStepDef (cucumber.runtime.java.spring.commonglue.OneStepDef)2 Test (org.junit.Test)2 ThirdStepDef (cucumber.runtime.java.spring.commonglue.ThirdStepDef)1