Search in sources :

Example 51 with MostUsefulConfiguration

use of org.jbehave.core.configuration.MostUsefulConfiguration in project jbehave-core by jbehave.

the class GuiceAnnotationBuilderBehaviour method shouldBuildDefaultConfigurationIfAnnotationOrAnnotatedValuesNotPresent.

@Test
public void shouldBuildDefaultConfigurationIfAnnotationOrAnnotatedValuesNotPresent() {
    AnnotationBuilder builderNotAnnotated = new GuiceAnnotationBuilder(NotAnnotated.class);
    assertThatConfigurationIs(builderNotAnnotated.buildConfiguration(), new MostUsefulConfiguration());
    AnnotationBuilder builderAnnotatedWithoutModules = new GuiceAnnotationBuilder(AnnotatedWithoutModules.class);
    assertThatConfigurationIs(builderAnnotatedWithoutModules.buildConfiguration(), new MostUsefulConfiguration());
}
Also used : AnnotationBuilder(org.jbehave.core.configuration.AnnotationBuilder) MostUsefulConfiguration(org.jbehave.core.configuration.MostUsefulConfiguration) Test(org.junit.Test)

Example 52 with MostUsefulConfiguration

use of org.jbehave.core.configuration.MostUsefulConfiguration in project jbehave-core by jbehave.

the class InstanceStepsFactoryBehaviour method shouldAllowGenericList.

@Test
public void shouldAllowGenericList() {
    List<? super MyInterface> list = new ArrayList<>();
    list.add(new MyStepsAWithInterface());
    list.add(new MyStepsBWithInterface());
    InstanceStepsFactory factory = new InstanceStepsFactory(new MostUsefulConfiguration(), list);
    List<CandidateSteps> candidateSteps = factory.createCandidateSteps();
    assertThat(candidateSteps.size(), equalTo(2));
}
Also used : MostUsefulConfiguration(org.jbehave.core.configuration.MostUsefulConfiguration) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 53 with MostUsefulConfiguration

use of org.jbehave.core.configuration.MostUsefulConfiguration in project jbehave-core by jbehave.

the class GuiceStepsFactoryBehaviour method assertThatStepsWithMissingDependenciesCannotBeCreated.

@Test(expected = CreationException.class)
public void assertThatStepsWithMissingDependenciesCannotBeCreated() throws NoSuchFieldException, IllegalAccessException {
    Injector parent = Guice.createInjector(new AbstractModule() {

        @Override
        protected void configure() {
            bind(FooStepsWithDependency.class);
        }
    });
    AbstractStepsFactory factory = new GuiceStepsFactory(new MostUsefulConfiguration(), parent);
    // When
    factory.createCandidateSteps();
// Then ... expected exception is thrown
}
Also used : Injector(com.google.inject.Injector) MostUsefulConfiguration(org.jbehave.core.configuration.MostUsefulConfiguration) AbstractStepsFactory(org.jbehave.core.steps.AbstractStepsFactory) AbstractModule(com.google.inject.AbstractModule) Test(org.junit.Test)

Example 54 with MostUsefulConfiguration

use of org.jbehave.core.configuration.MostUsefulConfiguration in project jbehave-core by jbehave.

the class GuiceStepsFactoryBehaviour method assertThatStepsCanBeCreated.

@Test
public void assertThatStepsCanBeCreated() throws NoSuchFieldException, IllegalAccessException {
    // Given
    Injector parent = Guice.createInjector(new AbstractModule() {

        @Override
        protected void configure() {
            bind(FooSteps.class).in(Scopes.SINGLETON);
        }
    });
    AbstractStepsFactory factory = new GuiceStepsFactory(new MostUsefulConfiguration(), parent);
    // When
    List<CandidateSteps> steps = factory.createCandidateSteps();
    // Then
    assertFooStepsFound(steps);
}
Also used : Injector(com.google.inject.Injector) MostUsefulConfiguration(org.jbehave.core.configuration.MostUsefulConfiguration) AbstractStepsFactory(org.jbehave.core.steps.AbstractStepsFactory) CandidateSteps(org.jbehave.core.steps.CandidateSteps) AbstractModule(com.google.inject.AbstractModule) Test(org.junit.Test)

Example 55 with MostUsefulConfiguration

use of org.jbehave.core.configuration.MostUsefulConfiguration in project jbehave-core by jbehave.

the class GuiceStepsFactoryBehaviour method assertThatStepsWithStepsWithDependencyCanBeCreated.

@Test
public void assertThatStepsWithStepsWithDependencyCanBeCreated() throws NoSuchFieldException, IllegalAccessException {
    Injector parent = Guice.createInjector(new AbstractModule() {

        @Override
        protected void configure() {
            bind(Integer.class).toInstance(42);
            bind(FooStepsWithDependency.class).in(Scopes.SINGLETON);
        }
    });
    // When
    AbstractStepsFactory factory = new GuiceStepsFactory(new MostUsefulConfiguration(), parent);
    List<CandidateSteps> steps = factory.createCandidateSteps();
    // Then
    assertFooStepsFound(steps);
    assertThat((int) ((FooStepsWithDependency) stepsInstance(steps.get(0))).integer, equalTo(42));
}
Also used : Injector(com.google.inject.Injector) MostUsefulConfiguration(org.jbehave.core.configuration.MostUsefulConfiguration) AbstractStepsFactory(org.jbehave.core.steps.AbstractStepsFactory) CandidateSteps(org.jbehave.core.steps.CandidateSteps) AbstractModule(com.google.inject.AbstractModule) Test(org.junit.Test)

Aggregations

MostUsefulConfiguration (org.jbehave.core.configuration.MostUsefulConfiguration)66 Test (org.junit.Test)52 Configuration (org.jbehave.core.configuration.Configuration)14 CandidateSteps (org.jbehave.core.steps.CandidateSteps)14 StoryReporterBuilder (org.jbehave.core.reporters.StoryReporterBuilder)11 LoadFromClasspath (org.jbehave.core.io.LoadFromClasspath)8 TableTransformers (org.jbehave.core.model.TableTransformers)8 Method (java.lang.reflect.Method)7 LocalizedKeywords (org.jbehave.core.i18n.LocalizedKeywords)7 ParameterConverters (org.jbehave.core.steps.ParameterConverters)7 SimpleDateFormat (java.text.SimpleDateFormat)5 HashMap (java.util.HashMap)5 InjectableEmbedder (org.jbehave.core.InjectableEmbedder)5 UsingEmbedder (org.jbehave.core.annotations.UsingEmbedder)5 BeforeOrAfterFailed (org.jbehave.core.failures.BeforeOrAfterFailed)5 Failed (org.jbehave.core.steps.AbstractStepResult.Failed)5 ApplicationContext (org.springframework.context.ApplicationContext)5 ByteArrayOutputStream (java.io.ByteArrayOutputStream)4 OutputStream (java.io.OutputStream)4 PrintStream (java.io.PrintStream)4