Search in sources :

Example 16 with CandidateSteps

use of org.jbehave.core.steps.CandidateSteps 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 17 with CandidateSteps

use of org.jbehave.core.steps.CandidateSteps 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)

Example 18 with CandidateSteps

use of org.jbehave.core.steps.CandidateSteps in project jbehave-core by jbehave.

the class Embedder method reportMatchingStepdocs.

public void reportMatchingStepdocs(String stepAsString) {
    Configuration configuration = configuration();
    List<CandidateSteps> candidateSteps = candidateSteps();
    StepFinder finder = configuration.stepFinder();
    StepdocReporter reporter = configuration.stepdocReporter();
    List<Stepdoc> matching = finder.findMatching(stepAsString, candidateSteps);
    List<Object> stepsInstances = finder.stepsInstances(candidateSteps);
    reporter.stepdocsMatching(stepAsString, matching, stepsInstances);
}
Also used : StepFinder(org.jbehave.core.steps.StepFinder) Configuration(org.jbehave.core.configuration.Configuration) MostUsefulConfiguration(org.jbehave.core.configuration.MostUsefulConfiguration) Stepdoc(org.jbehave.core.steps.Stepdoc) CandidateSteps(org.jbehave.core.steps.CandidateSteps) StepdocReporter(org.jbehave.core.reporters.StepdocReporter)

Example 19 with CandidateSteps

use of org.jbehave.core.steps.CandidateSteps in project jbehave-core by jbehave.

the class SpringStepsFactoryAOPBehaviour method aopEnvelopedStepsCanBeCreated.

@Test
public void aopEnvelopedStepsCanBeCreated() {
    // Given
    ApplicationContext context = createApplicationContext(StepsWithAOPAnnotationConfiguration.class.getName());
    SpringStepsFactory factory = new SpringStepsFactory(new MostUsefulConfiguration(), context);
    // When
    List<CandidateSteps> steps = factory.createCandidateSteps();
    // Then
    assertAOPFooStepsFound(steps);
}
Also used : ApplicationContext(org.springframework.context.ApplicationContext) MostUsefulConfiguration(org.jbehave.core.configuration.MostUsefulConfiguration) CandidateSteps(org.jbehave.core.steps.CandidateSteps) Test(org.junit.Test)

Example 20 with CandidateSteps

use of org.jbehave.core.steps.CandidateSteps in project jbehave-core by jbehave.

the class SpringStepsFactoryBehaviour method annotationStepsWithDependenciesCanBeCreated.

@Test
public void annotationStepsWithDependenciesCanBeCreated() {
    // Given
    ApplicationContext context = createApplicationContext(StepsWithDependencyAnnotationConfiguration.class.getName());
    // When
    SpringStepsFactory factory = new SpringStepsFactory(new MostUsefulConfiguration(), context);
    List<CandidateSteps> steps = factory.createCandidateSteps();
    // Then
    assertFooStepsFound(steps);
    assertThat((int) findInstanceOfType(steps, FooStepsWithDependency.class).integer, equalTo(42));
}
Also used : ApplicationContext(org.springframework.context.ApplicationContext) MostUsefulConfiguration(org.jbehave.core.configuration.MostUsefulConfiguration) CandidateSteps(org.jbehave.core.steps.CandidateSteps) Test(org.junit.Test)

Aggregations

CandidateSteps (org.jbehave.core.steps.CandidateSteps)29 Test (org.junit.Test)23 MostUsefulConfiguration (org.jbehave.core.configuration.MostUsefulConfiguration)18 Configuration (org.jbehave.core.configuration.Configuration)6 ApplicationContext (org.springframework.context.ApplicationContext)6 ByteArrayOutputStream (java.io.ByteArrayOutputStream)5 OutputStream (java.io.OutputStream)5 PrintStream (java.io.PrintStream)5 Matchers.containsString (org.hamcrest.Matchers.containsString)5 InjectableEmbedder (org.jbehave.core.InjectableEmbedder)5 UsingEmbedder (org.jbehave.core.annotations.UsingEmbedder)5 Embedder (org.jbehave.core.embedder.Embedder)5 StepFinder (org.jbehave.core.steps.StepFinder)5 PrintStreamStepdocReporter (org.jbehave.core.reporters.PrintStreamStepdocReporter)4 StoryPathResolver (org.jbehave.core.io.StoryPathResolver)3 InjectableStepsFactory (org.jbehave.core.steps.InjectableStepsFactory)3 Steps (org.jbehave.core.steps.Steps)3 AbstractModule (com.google.inject.AbstractModule)2 Injector (com.google.inject.Injector)2 ConfigurableEmbedder (org.jbehave.core.ConfigurableEmbedder)2