Search in sources :

Example 11 with StoryPathResolver

use of org.jbehave.core.io.StoryPathResolver in project jbehave-core by jbehave.

the class ConfigurableEmbedderBehaviour method shouldAllowOverrideOfDefaultConfiguration.

@Test
public void shouldAllowOverrideOfDefaultConfiguration() throws Throwable {
    // Given
    Embedder embedder = mock(Embedder.class);
    Configuration configuration = mock(Configuration.class);
    StoryPathResolver pathResolver = mock(StoryPathResolver.class);
    when(embedder.configuration()).thenReturn(configuration);
    when(configuration.storyPathResolver()).thenReturn(pathResolver);
    Class<MyStory> storyClass = MyStory.class;
    String storyPath = "/path/to/story";
    when(pathResolver.resolve(storyClass)).thenReturn(storyPath);
    CandidateSteps steps = mock(CandidateSteps.class);
    // When
    MyStory story = new MyStory(new MostUsefulConfiguration(), steps);
    assertThat(story.configuration(), is(not(sameInstance(configuration))));
    story.useConfiguration(configuration);
    assertThat(story.configuration(), is(sameInstance(configuration)));
    story.useEmbedder(embedder);
    story.run();
    // Then
    verify(embedder).useConfiguration(configuration);
    verify(embedder).useCandidateSteps(Mockito.eq(Arrays.asList(steps)));
    verify(embedder).runStoriesAsPaths(asList(storyPath));
}
Also used : StoryPathResolver(org.jbehave.core.io.StoryPathResolver) MostUsefulConfiguration(org.jbehave.core.configuration.MostUsefulConfiguration) Configuration(org.jbehave.core.configuration.Configuration) MostUsefulConfiguration(org.jbehave.core.configuration.MostUsefulConfiguration) Embedder(org.jbehave.core.embedder.Embedder) CandidateSteps(org.jbehave.core.steps.CandidateSteps) Test(org.junit.Test)

Example 12 with StoryPathResolver

use of org.jbehave.core.io.StoryPathResolver in project jbehave-core by jbehave.

the class ConfigurableEmbedderBehaviour method shouldRunASingleStory.

@Test
public void shouldRunASingleStory() throws Throwable {
    // Given
    Embedder embedder = mock(Embedder.class);
    Configuration configuration = mock(Configuration.class);
    StoryPathResolver pathResolver = mock(StoryPathResolver.class);
    when(embedder.configuration()).thenReturn(configuration);
    when(configuration.storyPathResolver()).thenReturn(pathResolver);
    Class<MyStory> storyClass = MyStory.class;
    String storyPath = "/path/to/story";
    when(pathResolver.resolve(storyClass)).thenReturn(storyPath);
    CandidateSteps steps = mock(CandidateSteps.class);
    // When
    MyStory story = new MyStory(configuration, steps);
    story.useEmbedder(embedder);
    story.run();
    // Then
    verify(embedder).useConfiguration(configuration);
    verify(embedder).useCandidateSteps(eq(asList(steps)));
    verify(embedder).runStoriesAsPaths(asList(storyPath));
}
Also used : StoryPathResolver(org.jbehave.core.io.StoryPathResolver) MostUsefulConfiguration(org.jbehave.core.configuration.MostUsefulConfiguration) Configuration(org.jbehave.core.configuration.Configuration) Embedder(org.jbehave.core.embedder.Embedder) CandidateSteps(org.jbehave.core.steps.CandidateSteps) Test(org.junit.Test)

Aggregations

StoryPathResolver (org.jbehave.core.io.StoryPathResolver)12 Test (org.junit.Test)12 Configuration (org.jbehave.core.configuration.Configuration)11 MostUsefulConfiguration (org.jbehave.core.configuration.MostUsefulConfiguration)11 ByteArrayOutputStream (java.io.ByteArrayOutputStream)8 OutputStream (java.io.OutputStream)8 PrintStream (java.io.PrintStream)8 ArrayList (java.util.ArrayList)8 HashMap (java.util.HashMap)8 Matchers.containsString (org.hamcrest.Matchers.containsString)8 InjectableEmbedder (org.jbehave.core.InjectableEmbedder)8 UsingEmbedder (org.jbehave.core.annotations.UsingEmbedder)8 JUnitStory (org.jbehave.core.junit.JUnitStory)8 Story (org.jbehave.core.model.Story)8 RunContext (org.jbehave.core.embedder.PerformableTree.RunContext)7 BatchFailures (org.jbehave.core.failures.BatchFailures)7 InjectableStepsFactory (org.jbehave.core.steps.InjectableStepsFactory)7 Embedder (org.jbehave.core.embedder.Embedder)4 CandidateSteps (org.jbehave.core.steps.CandidateSteps)3 StoryReporter (org.jbehave.core.reporters.StoryReporter)2