use of org.jbehave.core.embedder.Embedder 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.embedder.Embedder 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.embedder.Embedder 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));
}
use of org.jbehave.core.embedder.Embedder in project jbehave-core by jbehave.
the class AnnotationBuilderBehaviour method shouldCreateEmbeddableInstanceFromConfigurableEmbedder.
@Test
public void shouldCreateEmbeddableInstanceFromConfigurableEmbedder() {
AnnotationBuilder annotatedConfigurable = new AnnotationBuilder(AnnotedConfigurable.class);
Object instance = annotatedConfigurable.embeddableInstance();
assertThat(instance, Matchers.instanceOf(ConfigurableEmbedder.class));
Embedder embedder = ((ConfigurableEmbedder) instance).configuredEmbedder();
assertThat(embedder.configuration().keywords(), instanceOf(MyKeywords.class));
assertThat(embedder.metaFilters(), equalTo(asList("+embedder configurable")));
assertThatStepsInstancesAre(embedder.stepsFactory().createCandidateSteps(), MySteps.class);
}
use of org.jbehave.core.embedder.Embedder in project jbehave-core by jbehave.
the class AnnotationBuilderBehaviour method shouldCreateEmbeddableInstanceFromConfigurableEmbedderWithoutStepsFactory.
@Test
public void shouldCreateEmbeddableInstanceFromConfigurableEmbedderWithoutStepsFactory() {
AnnotationBuilder annotatedConfigurable = new AnnotationBuilder(AnnotedConfigurableWithoutStepsFactory.class);
Object instance = annotatedConfigurable.embeddableInstance();
assertThat(instance, Matchers.instanceOf(ConfigurableEmbedder.class));
Embedder embedder = ((ConfigurableEmbedder) instance).configuredEmbedder();
assertThat(embedder.configuration().keywords(), instanceOf(MyKeywords.class));
assertThat(embedder.metaFilters(), equalTo(asList("+embedder configurable")));
assertThatStepsInstancesAre(embedder.candidateSteps(), MySteps.class);
}
Aggregations