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);
}
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());
}
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());
}
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());
}
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"));
}
Aggregations