Search in sources :

Example 16 with MostUsefulConfiguration

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

the class InstanceStepsFactoryBehaviour method shouldCreateCandidateSteps.

@Test
public void shouldCreateCandidateSteps() {
    InjectableStepsFactory factory = new InstanceStepsFactory(new MostUsefulConfiguration(), new MySteps());
    List<CandidateSteps> candidateSteps = factory.createCandidateSteps();
    assertThat(candidateSteps.size(), equalTo(1));
    assertThat(candidateSteps.get(0), instanceOf(Steps.class));
    ParameterConverters converters = ((Steps) candidateSteps.get(0)).configuration().parameterConverters();
    assertThat((String) converters.convert("value", String.class), equalTo("valueConverted"));
}
Also used : MostUsefulConfiguration(org.jbehave.core.configuration.MostUsefulConfiguration) Test(org.junit.Test)

Example 17 with MostUsefulConfiguration

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

the class ReportTransformBehaviour method runStories.

private void runStories(String... storyPaths) {
    StoryReporterBuilder storyReporterBuilder = new StoryReporterBuilder().withDefaultFormats().withCodeLocation(CodeLocations.codeLocationFromClass(ReportTransformBehaviour.class)).withFormats(Format.XML);
    Configuration configuration = new MostUsefulConfiguration().useStoryLoader(new LoadFromClasspath(this.getClass())).useStoryReporterBuilder(storyReporterBuilder).useFailureStrategy(new SilentlyAbsorbingFailure()).useStepCollector(new MarkUnmatchedStepsAsPending(new StepFinder(new ByLevenshteinDistance())));
    Embedder embedder = new Embedder();
    embedder.useEmbedderControls(new EmbedderControls().doGenerateViewAfterStories(false));
    embedder.useConfiguration(configuration);
    embedder.useCandidateSteps(new InstanceStepsFactory(configuration, new MySteps()).createCandidateSteps());
    embedder.useMetaFilters(asList("-skip true"));
    try {
        embedder.runStoriesAsPaths(asList(storyPaths));
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : StoryReporterBuilder(org.jbehave.core.reporters.StoryReporterBuilder) StepFinder(org.jbehave.core.steps.StepFinder) Configuration(org.jbehave.core.configuration.Configuration) MostUsefulConfiguration(org.jbehave.core.configuration.MostUsefulConfiguration) MostUsefulConfiguration(org.jbehave.core.configuration.MostUsefulConfiguration) Embedder(org.jbehave.core.embedder.Embedder) FileNotFoundException(java.io.FileNotFoundException) SilentlyAbsorbingFailure(org.jbehave.core.failures.SilentlyAbsorbingFailure) ByLevenshteinDistance(org.jbehave.core.steps.StepFinder.ByLevenshteinDistance) LoadFromClasspath(org.jbehave.core.io.LoadFromClasspath) InstanceStepsFactory(org.jbehave.core.steps.InstanceStepsFactory) EmbedderControls(org.jbehave.core.embedder.EmbedderControls) MarkUnmatchedStepsAsPending(org.jbehave.core.steps.MarkUnmatchedStepsAsPending)

Example 18 with MostUsefulConfiguration

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

the class GroovyAnnotationBuilderBehaviour method shouldBuildConfigurationFromAnnotations.

@Test
public void shouldBuildConfigurationFromAnnotations() {
    GroovyAnnotationBuilder builder = new GroovyAnnotationBuilder(AnnotatedUsingGroovy.class);
    assertThatConfigurationIs(builder.buildConfiguration(), new MostUsefulConfiguration());
}
Also used : MostUsefulConfiguration(org.jbehave.core.configuration.MostUsefulConfiguration) Test(org.junit.Test)

Example 19 with MostUsefulConfiguration

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

the class GroovyStepsFactoryBehaviour method shouldNotCreateStepsInstancesFromGroovyWhenResourceInvalid.

@Test(expected = GroovyClassInstantiationFailed.class)
public void shouldNotCreateStepsInstancesFromGroovyWhenResourceInvalid() {
    GroovyStepsFactory factory = new GroovyStepsFactory(new MostUsefulConfiguration(), new GroovyContext(asList("/org/jbehave/core/steps/groovy/invalidSteps.groovy")));
    factory.stepsTypes();
}
Also used : MostUsefulConfiguration(org.jbehave.core.configuration.MostUsefulConfiguration) GroovyContext(org.jbehave.core.configuration.groovy.GroovyContext) Test(org.junit.Test)

Example 20 with MostUsefulConfiguration

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

the class GroovyStepsFactoryBehaviour method shouldCreateStepsInstancesFromGroovyWhenAnnotated.

@Test
public void shouldCreateStepsInstancesFromGroovyWhenAnnotated() {
    GroovyResourceFinder resourceFinder = new GroovyResourceFinder(codeLocationFromClass(this.getClass()), "**/steps/groovy/*.groovy", "**/invalidSteps.groovy");
    GroovyStepsFactory factory = new GroovyStepsFactory(new MostUsefulConfiguration(), new GroovyContext(resourceFinder));
    List<Class<?>> types = factory.stepsTypes();
    MatcherAssert.assertThat(types.size(), Matchers.equalTo(1));
    assertThat(types.get(0).getSimpleName(), equalTo("AnnotatedSteps"));
}
Also used : GroovyResourceFinder(org.jbehave.core.configuration.groovy.GroovyResourceFinder) MostUsefulConfiguration(org.jbehave.core.configuration.MostUsefulConfiguration) CodeLocations.codeLocationFromClass(org.jbehave.core.io.CodeLocations.codeLocationFromClass) GroovyContext(org.jbehave.core.configuration.groovy.GroovyContext) 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