Search in sources :

Example 21 with CandidateSteps

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

the class NeedleStepsFactory method createCandidateSteps.

/**
 * {@inheritDoc}
 */
public List<CandidateSteps> createCandidateSteps() {
    final List<CandidateSteps> result = new ArrayList<>();
    for (final Class<?> type : steps) {
        if (hasAnnotatedMethods(type)) {
            configuration.parameterConverters().addConverters(methodReturningConverters(type));
            result.add(new Steps(configuration, type, this));
        }
    }
    return result;
}
Also used : Steps(org.jbehave.core.steps.Steps) CandidateSteps(org.jbehave.core.steps.CandidateSteps) ArrayList(java.util.ArrayList) CandidateSteps(org.jbehave.core.steps.CandidateSteps)

Example 22 with CandidateSteps

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

the class NeedleAnnotationBuilderBehaviour method assertThatStepsInstancesAre.

private void assertThatStepsInstancesAre(final List<CandidateSteps> candidateSteps, final Class<?>... stepsClasses) {
    assertThat(candidateSteps.size(), equalTo(stepsClasses.length));
    // transform candidateSteps to Set of classes
    final Set<Class<?>> candidateStepClasses = new HashSet<>();
    for (final CandidateSteps step : candidateSteps) {
        candidateStepClasses.add(((Steps) step).instance().getClass());
    }
    assertThat(candidateStepClasses, hasItems(stepsClasses));
}
Also used : Steps(org.jbehave.core.steps.Steps) CandidateSteps(org.jbehave.core.steps.CandidateSteps) UsingSteps(org.jbehave.core.annotations.UsingSteps) FooSteps(org.jbehave.core.steps.needle.NeedleStepsFactoryBehaviour.FooSteps) CandidateSteps(org.jbehave.core.steps.CandidateSteps) HashSet(java.util.HashSet)

Example 23 with CandidateSteps

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

the class NeedleAnnotationBuilderBehaviour method shouldBuildStepsList.

@Test
public void shouldBuildStepsList() {
    final AnnotationBuilder builderAnnotated = new NeedleAnnotationBuilder(AnnotatedMultipleSteps.class);
    final List<CandidateSteps> actual = builderAnnotated.buildCandidateSteps();
    assertThatStepsInstancesAre(actual, FooStepsWithDependency.class, FooSteps.class);
}
Also used : AnnotationBuilder(org.jbehave.core.configuration.AnnotationBuilder) CandidateSteps(org.jbehave.core.steps.CandidateSteps) Test(org.junit.Test)

Example 24 with CandidateSteps

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

the class SpringStepsFactoryBehaviour method stepsCanBeCreated.

@Test
public void stepsCanBeCreated() {
    // Given
    ApplicationContext context = createApplicationContext("org/jbehave/core/steps/spring/steps.xml");
    SpringStepsFactory factory = new SpringStepsFactory(new MostUsefulConfiguration(), context);
    // When
    List<CandidateSteps> steps = factory.createCandidateSteps();
    // Then
    assertFooStepsFound(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 25 with CandidateSteps

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

the class SpringStepsFactoryBehaviour method stepsWithDependenciesCanBeCreated.

@Test
public void stepsWithDependenciesCanBeCreated() {
    // Given
    ApplicationContext context = createApplicationContext("org/jbehave/core/steps/spring/steps-with-dependency.xml");
    // 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