use of org.jbehave.core.steps.CandidateSteps in project jbehave-core by jbehave.
the class EmbedderBehaviour method shouldReportNoMatchingStepdocsFoundWithStepProvided.
@Test
public void shouldReportNoMatchingStepdocsFoundWithStepProvided() {
// Given
Embedder embedder = new Embedder();
embedder.useCandidateSteps(asList((CandidateSteps) new MySteps()));
embedder.configuration().useStepFinder(new StepFinder());
OutputStream out = new ByteArrayOutputStream();
embedder.configuration().useStepdocReporter(new PrintStreamStepdocReporter(new PrintStream(out)));
// When
embedder.reportMatchingStepdocs("Given a non-defined step");
// Then
String expected = "Step 'Given a non-defined step' is not matched by any pattern\n" + "from steps instances:\n" + "org.jbehave.core.embedder.EmbedderBehaviour$MySteps\n";
assertThat(dos2unix(out.toString()), equalTo(expected));
}
use of org.jbehave.core.steps.CandidateSteps in project jbehave-core by jbehave.
the class EmbedderBehaviour method shouldReportAllStepdocs.
@Test
public void shouldReportAllStepdocs() {
// Given
Embedder embedder = new Embedder();
embedder.useCandidateSteps(asList((CandidateSteps) new MySteps()));
embedder.configuration().useStepFinder(new StepFinder());
OutputStream out = new ByteArrayOutputStream();
embedder.configuration().useStepdocReporter(new PrintStreamStepdocReporter(new PrintStream(out)));
// When
embedder.reportStepdocs();
// Then
String output = dos2unix(out.toString());
assertThat(output, containsString("'Given a given'\n" + "org.jbehave.core.embedder.EmbedderBehaviour$MySteps.given()\n"));
assertThat(output, containsString("'When a when'\n" + "org.jbehave.core.embedder.EmbedderBehaviour$MySteps.when()\n"));
assertThat(output, containsString("'Then a then'\n" + "org.jbehave.core.embedder.EmbedderBehaviour$MySteps.then()\n"));
assertThat(output, containsString("from steps instances:\norg.jbehave.core.embedder.EmbedderBehaviour$MySteps\n"));
}
use of org.jbehave.core.steps.CandidateSteps in project jbehave-core by jbehave.
the class ConfigurableEmbedderBehaviour method shouldRunMultipleStories.
@Test
public void shouldRunMultipleStories() throws Throwable {
// Given
Embedder embedder = mock(Embedder.class);
Configuration configuration = mock(Configuration.class);
CandidateSteps steps = mock(CandidateSteps.class);
// When
MyStories story = new MyStories(configuration, steps);
story.useEmbedder(embedder);
story.run();
// Then
verify(embedder).runStoriesAsPaths(asList("org/jbehave/core/story1", "org/jbehave/core/story2"));
}
use of org.jbehave.core.steps.CandidateSteps 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));
}
use of org.jbehave.core.steps.CandidateSteps 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));
}
Aggregations