Search in sources :

Example 26 with Configuration

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

the class WeldAnnotationBuilderBehaviour method shouldBuildConfigurationFromAnnotationsUsingConfigureAndConverters.

@Test
public void shouldBuildConfigurationFromAnnotationsUsingConfigureAndConverters() {
    AnnotationBuilder builderAnnotated = createBuilder(AnnotatedUsingConfigureAndConverters.class);
    Configuration configuration = builderAnnotated.buildConfiguration();
    assertThatCustomObjectIsConverted(configuration.parameterConverters());
    assertThatDateIsConvertedWithFormat(configuration.parameterConverters(), new SimpleDateFormat("yyyy-MM-dd"));
}
Also used : Configuration(org.jbehave.core.configuration.Configuration) MostUsefulConfiguration(org.jbehave.core.configuration.MostUsefulConfiguration) AnnotationBuilder(org.jbehave.core.configuration.AnnotationBuilder) SimpleDateFormat(java.text.SimpleDateFormat) Test(org.junit.Test)

Example 27 with Configuration

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

the class WeldAnnotationBuilderBehaviour method shouldBuildCandidateStepsFromAnnotationsUsingWeld.

@Test
public void shouldBuildCandidateStepsFromAnnotationsUsingWeld() {
    AnnotationBuilder builderAnnotated = createBuilder(AnnotatedUsingWeld.class);
    Configuration configuration = builderAnnotated.buildConfiguration();
    assertThatStepsInstancesAre(builderAnnotated.buildCandidateSteps(configuration), WeldStepBean.class);
}
Also used : Configuration(org.jbehave.core.configuration.Configuration) MostUsefulConfiguration(org.jbehave.core.configuration.MostUsefulConfiguration) AnnotationBuilder(org.jbehave.core.configuration.AnnotationBuilder) Test(org.junit.Test)

Example 28 with Configuration

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

the class NeedleAnnotationBuilderBehaviour method shouldBuildCandidateStepsFromAnnotationsUsingStepsAndNeedle.

@Test
public void shouldBuildCandidateStepsFromAnnotationsUsingStepsAndNeedle() {
    final AnnotationBuilder builderAnnotated = new NeedleAnnotationBuilder(AnnotatedUsingStepsAndNeedle.class);
    final Configuration configuration = builderAnnotated.buildConfiguration();
    assertThatStepsInstancesAre(builderAnnotated.buildCandidateSteps(configuration), FooSteps.class);
}
Also used : Configuration(org.jbehave.core.configuration.Configuration) MostUsefulConfiguration(org.jbehave.core.configuration.MostUsefulConfiguration) AnnotationBuilder(org.jbehave.core.configuration.AnnotationBuilder) Test(org.junit.Test)

Example 29 with Configuration

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

the class SpringSecurityStories method configuration.

@Override
public Configuration configuration() {
    Configuration configuration = new MostUsefulConfiguration();
    configuration.useStoryReporterBuilder(new StoryReporterBuilder().withCodeLocation(CodeLocations.codeLocationFromClass(getClass())).withDefaultFormats().withFormats(CONSOLE, TXT, HTML, XML));
    return configuration;
}
Also used : StoryReporterBuilder(org.jbehave.core.reporters.StoryReporterBuilder) MostUsefulConfiguration(org.jbehave.core.configuration.MostUsefulConfiguration) Configuration(org.jbehave.core.configuration.Configuration) MostUsefulConfiguration(org.jbehave.core.configuration.MostUsefulConfiguration)

Example 30 with Configuration

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

the class EmbedderBehaviour method shouldRunStoriesAsPathsInBatchIfBatchFlagIsSet.

@SuppressWarnings("unchecked")
@Test
public void shouldRunStoriesAsPathsInBatchIfBatchFlagIsSet() throws Throwable {
    // Given
    PerformableTree performableTree = mock(PerformableTree.class);
    EmbedderControls embedderControls = new EmbedderControls().doBatch(true);
    OutputStream out = new ByteArrayOutputStream();
    EmbedderMonitor monitor = new PrintStreamEmbedderMonitor(new PrintStream(out));
    List<? extends Class<? extends Embeddable>> embeddables = asList(MyStory.class, MyOtherEmbeddable.class);
    Embedder embedder = embedderWith(performableTree, embedderControls, monitor);
    Configuration configuration = embedder.configuration();
    InjectableStepsFactory stepsFactory = embedder.stepsFactory();
    MetaFilter filter = embedder.metaFilter();
    StoryPathResolver resolver = configuration.storyPathResolver();
    List<String> storyPaths = new ArrayList<>();
    Map<String, Story> stories = new HashMap<>();
    for (Class<? extends Embeddable> embeddable : embeddables) {
        String storyPath = resolver.resolve(embeddable);
        storyPaths.add(storyPath);
        Story story = mockStory(Meta.EMPTY);
        stories.put(storyPath, story);
        when(performableTree.storyOfPath(configuration, storyPath)).thenReturn(story);
        when(story.getPath()).thenReturn(storyPath);
    }
    RunContext runContext = new RunContext(configuration, stepsFactory, monitor, filter, new BatchFailures());
    when(performableTree.newRunContext(isA(Configuration.class), isA(InjectableStepsFactory.class), isA(EmbedderMonitor.class), isA(MetaFilter.class), isA(BatchFailures.class))).thenReturn(runContext);
    for (String storyPath : storyPaths) {
        doNothing().when(performableTree).perform(runContext, stories.get(storyPath));
    }
    // When
    embedder.runStoriesAsPaths(storyPaths);
    // Then
    for (String storyPath : storyPaths) {
        assertThat(out.toString(), containsString("Running story " + storyPath));
    }
}
Also used : PrintStream(java.io.PrintStream) InjectableStepsFactory(org.jbehave.core.steps.InjectableStepsFactory) StoryPathResolver(org.jbehave.core.io.StoryPathResolver) Configuration(org.jbehave.core.configuration.Configuration) MostUsefulConfiguration(org.jbehave.core.configuration.MostUsefulConfiguration) HashMap(java.util.HashMap) ByteArrayOutputStream(java.io.ByteArrayOutputStream) OutputStream(java.io.OutputStream) ArrayList(java.util.ArrayList) InjectableEmbedder(org.jbehave.core.InjectableEmbedder) UsingEmbedder(org.jbehave.core.annotations.UsingEmbedder) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Matchers.containsString(org.hamcrest.Matchers.containsString) BatchFailures(org.jbehave.core.failures.BatchFailures) RunContext(org.jbehave.core.embedder.PerformableTree.RunContext) JUnitStory(org.jbehave.core.junit.JUnitStory) Story(org.jbehave.core.model.Story) Test(org.junit.Test)

Aggregations

Configuration (org.jbehave.core.configuration.Configuration)64 MostUsefulConfiguration (org.jbehave.core.configuration.MostUsefulConfiguration)61 Test (org.junit.Test)55 AnnotationBuilder (org.jbehave.core.configuration.AnnotationBuilder)18 StoryReporter (org.jbehave.core.reporters.StoryReporter)15 ConcurrentStoryReporter (org.jbehave.core.reporters.ConcurrentStoryReporter)13 StoryPathResolver (org.jbehave.core.io.StoryPathResolver)11 ByteArrayOutputStream (java.io.ByteArrayOutputStream)10 OutputStream (java.io.OutputStream)10 PrintStream (java.io.PrintStream)10 Matchers.containsString (org.hamcrest.Matchers.containsString)10 InjectableEmbedder (org.jbehave.core.InjectableEmbedder)10 UsingEmbedder (org.jbehave.core.annotations.UsingEmbedder)10 AbstractStep (org.jbehave.core.steps.StepCreator.AbstractStep)10 ArrayList (java.util.ArrayList)9 HashMap (java.util.HashMap)8 JUnitStory (org.jbehave.core.junit.JUnitStory)8 Story (org.jbehave.core.model.Story)8 SimpleDateFormat (java.text.SimpleDateFormat)7 RunContext (org.jbehave.core.embedder.PerformableTree.RunContext)7