Search in sources :

Example 21 with ObjectFactory

use of cucumber.api.java.ObjectFactory in project cucumber-jvm by cucumber.

the class PicoFactoryTest method shouldGiveUsNewInstancesForEachScenario.

@Test
public void shouldGiveUsNewInstancesForEachScenario() {
    ObjectFactory factory = new PicoFactory();
    factory.addClass(StepDefs.class);
    // Scenario 1
    factory.start();
    StepDefs o1 = factory.getInstance(StepDefs.class);
    factory.stop();
    // Scenario 2
    factory.start();
    StepDefs o2 = factory.getInstance(StepDefs.class);
    factory.stop();
    assertNotNull(o1);
    assertNotSame(o1, o2);
}
Also used : ObjectFactory(cucumber.api.java.ObjectFactory) Test(org.junit.Test)

Example 22 with ObjectFactory

use of cucumber.api.java.ObjectFactory in project cucumber-jvm by cucumber.

the class SpringFactoryTest method shouldUseCucumberXmlIfNoClassWithSpringAnnotationIsFound.

@Test
public void shouldUseCucumberXmlIfNoClassWithSpringAnnotationIsFound() {
    final ObjectFactory factory = new SpringFactory();
    factory.addClass(AutowiresPlatformTransactionManager.class);
    factory.start();
    final AutowiresPlatformTransactionManager o1 = factory.getInstance(AutowiresPlatformTransactionManager.class);
    factory.stop();
    assertNotNull(o1);
    assertNotNull(o1.getTransactionManager());
}
Also used : ObjectFactory(cucumber.api.java.ObjectFactory) AutowiresPlatformTransactionManager(cucumber.runtime.java.spring.commonglue.AutowiresPlatformTransactionManager) Test(org.junit.Test)

Example 23 with ObjectFactory

use of cucumber.api.java.ObjectFactory in project cucumber-jvm by cucumber.

the class JavaBackendTest method finds_step_definitions_by_classpath_url.

@Test
public void finds_step_definitions_by_classpath_url() {
    ObjectFactory factory = new DefaultJavaObjectFactory();
    JavaBackend backend = new JavaBackend(factory);
    GlueStub glue = new GlueStub();
    backend.loadGlue(glue, asList("classpath:cucumber/runtime/java/stepdefs"));
    backend.buildWorld();
    assertEquals(Stepdefs.class, factory.getInstance(Stepdefs.class).getClass());
}
Also used : ObjectFactory(cucumber.api.java.ObjectFactory) Test(org.junit.Test)

Example 24 with ObjectFactory

use of cucumber.api.java.ObjectFactory in project cucumber-jvm by cucumber.

the class JavaBackendTest method finds_step_definitions_by_package_name.

@Test
public void finds_step_definitions_by_package_name() {
    ObjectFactory factory = new DefaultJavaObjectFactory();
    JavaBackend backend = new JavaBackend(factory);
    GlueStub glue = new GlueStub();
    backend.loadGlue(glue, asList("cucumber.runtime.java.stepdefs"));
    backend.buildWorld();
    assertEquals(Stepdefs.class, factory.getInstance(Stepdefs.class).getClass());
}
Also used : ObjectFactory(cucumber.api.java.ObjectFactory) Test(org.junit.Test)

Example 25 with ObjectFactory

use of cucumber.api.java.ObjectFactory in project cucumber-jvm by cucumber.

the class JavaBackendTest method detects_subclassed_glue_and_throws_exception.

@Test(expected = CucumberException.class)
public void detects_subclassed_glue_and_throws_exception() {
    ObjectFactory factory = new DefaultJavaObjectFactory();
    JavaBackend backend = new JavaBackend(factory);
    GlueStub glue = new GlueStub();
    backend.loadGlue(glue, asList("cucumber.runtime.java.stepdefs", "cucumber.runtime.java.incorrectlysubclassedstepdefs"));
}
Also used : ObjectFactory(cucumber.api.java.ObjectFactory) 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