use of org.jbehave.core.embedder.StoryRunner.State in project jbehave-core by jbehave.
the class StoryRunnerBehaviour method shouldReportStoryCancellation.
@Test
public void shouldReportStoryCancellation() {
// Given
Configuration configuration = mock(Configuration.class, Mockito.RETURNS_DEEP_STUBS);
when(configuration.storyControls().dryRun()).thenReturn(false);
StoryReporter reporter = mock(ConcurrentStoryReporter.class);
when(configuration.storyReporter(Matchers.anyString())).thenReturn(reporter);
Story story = mock(Story.class);
String storyPath = "story/path";
when(story.getPath()).thenReturn(storyPath);
RuntimeException expected = new RuntimeException();
when(story.getMeta()).thenThrow(expected);
InjectableStepsFactory stepsFactory = mock(InjectableStepsFactory.class);
MetaFilter metaFilter = mock(MetaFilter.class);
State state = mock(State.class);
// When
long durationInSecs = 2;
long timeoutInSecs = 1;
StoryDuration storyDuration = new StoryDuration(timeoutInSecs);
try {
StoryRunner runner = new StoryRunner();
runner.cancelStory(story, storyDuration);
runner.run(configuration, stepsFactory, story, metaFilter, state);
throw new AssertionError("A exception should be thrown");
} catch (Throwable e) {
// Then
assertThat(e.equals(expected), is(true));
}
verify(reporter).storyCancelled(story, storyDuration);
}
Aggregations