use of org.jbehave.core.embedder.Embedder in project jbehave-core by jbehave.
the class ConfigurableEmbedderBehaviour method shouldAllowAdditionOfSteps.
@Test
public void shouldAllowAdditionOfSteps() 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).runStoriesAsPaths(asList(storyPath));
}
use of org.jbehave.core.embedder.Embedder in project jbehave-core by jbehave.
the class InjectableEmbedderBehaviour method shouldRunStoriesAsPathsUsingInjected.
@Test
public void shouldRunStoriesAsPathsUsingInjected() throws Throwable {
// Given
Embedder embedder = mock(Embedder.class);
// When
StoriesAsPaths stories = new StoriesAsPaths();
stories.useEmbedder(embedder);
stories.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 AnnotationBuilderBehaviour method shouldCreateEmbeddableInstanceFromInjectableEmbedderWithoutStepsFactory.
@Test
public void shouldCreateEmbeddableInstanceFromInjectableEmbedderWithoutStepsFactory() {
AnnotationBuilder annotatedInjectable = new AnnotationBuilder(AnnotedInjectableWithoutStepsFactory.class);
Object instance = annotatedInjectable.embeddableInstance();
assertThat(instance, Matchers.instanceOf(InjectableEmbedder.class));
Embedder embedder = ((InjectableEmbedder) instance).injectedEmbedder();
assertThat(embedder.configuration().keywords(), instanceOf(MyKeywords.class));
assertThat(embedder.metaFilters(), equalTo(asList("+embedder injectable")));
assertThatStepsInstancesAre(embedder.candidateSteps(), MySteps.class);
}
use of org.jbehave.core.embedder.Embedder in project jbehave-core by jbehave.
the class AnnotationBuilderBehaviour method shouldCreateEmbeddableInstanceFromInjectableEmbedder.
@Test
public void shouldCreateEmbeddableInstanceFromInjectableEmbedder() {
AnnotationBuilder annotatedInjectable = new AnnotationBuilder(AnnotedInjectable.class);
Object instance = annotatedInjectable.embeddableInstance();
assertThat(instance, Matchers.instanceOf(InjectableEmbedder.class));
Embedder embedder = ((InjectableEmbedder) instance).injectedEmbedder();
assertThat(embedder.configuration().keywords(), instanceOf(MyKeywords.class));
assertThat(embedder.metaFilters(), equalTo(asList("+embedder injectable")));
assertThat(embedder.systemProperties().getProperty("one"), equalTo("One"));
assertThat(embedder.systemProperties().getProperty("two"), equalTo("Two"));
assertThatStepsInstancesAre(embedder.stepsFactory().createCandidateSteps(), MySteps.class);
}
use of org.jbehave.core.embedder.Embedder 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();
}
}
Aggregations