use of org.jbehave.core.model.Story in project jbehave-core by jbehave.
the class GherkinStoryParserBehaviour method shouldParseStoryWithAlternativeNarrative.
@Test
public void shouldParseStoryWithAlternativeNarrative() throws IOException {
String storyAsText = "Feature: Hello Car\n" + "Narrative:\n" + "As a car driver\n" + "I want to drive cars on 4 wheels\n" + "So that I can feel safer\n" + "Scenario: Car can drive\n" + "Given I have a car with 4 wheels\n" + "Then I can drive it.\n";
Story story = storyParser.parseStory(storyAsText);
assertThat(story.getDescription().asString(), equalTo("Hello Car"));
Narrative narrative = story.getNarrative();
assertThat(narrative.asA(), equalTo("car driver"));
assertThat(narrative.iWantTo(), equalTo("drive cars on 4 wheels"));
assertThat(narrative.soThat(), equalTo("I can feel safer"));
}
use of org.jbehave.core.model.Story in project jbehave-core by jbehave.
the class StoryManager method waitUntilAllDoneOrFailed.
public void waitUntilAllDoneOrFailed(RunContext context) {
if (runningStories.values().isEmpty()) {
return;
}
boolean allDone = false;
boolean started = false;
while (!allDone || !started) {
allDone = true;
for (RunningStory runningStory : runningStories.values()) {
if (runningStory.isStarted()) {
started = true;
Story story = runningStory.getStory();
Future<ThrowableStory> future = runningStory.getFuture();
if (!future.isDone()) {
allDone = false;
StoryDuration duration = runningStory.getDuration();
runningStory.updateDuration();
if (duration.timedOut()) {
embedderMonitor.storyTimeout(story, duration);
context.cancelStory(story, duration);
future.cancel(true);
if (embedderControls.failOnStoryTimeout()) {
throw new StoryExecutionFailed(story.getPath(), new StoryTimedOut(duration));
}
continue;
}
} else {
try {
ThrowableStory throwableStory = future.get();
Throwable throwable = throwableStory.getThrowable();
if (throwable != null) {
context.addFailure(story.getPath(), throwable);
if (!embedderControls.ignoreFailureInStories()) {
continue;
}
}
} catch (Throwable e) {
context.addFailure(story.getPath(), e);
if (!embedderControls.ignoreFailureInStories()) {
continue;
}
}
}
} else {
started = false;
allDone = false;
}
}
tickTock();
}
writeStoryDurations(runningStories.values());
}
use of org.jbehave.core.model.Story in project jbehave-core by jbehave.
the class StoryRunner method runGivenStories.
private void runGivenStories(GivenStories givenStories, Map<String, String> parameters, RunContext context) throws Throwable {
if (givenStories.getPaths().size() > 0) {
reporter.get().givenStories(givenStories);
for (GivenStory givenStory : givenStories.getStories()) {
RunContext childContext = context.childContextFor(givenStory);
// run given story, using any parameters provided
Story story = storyOfPath(context.configuration(), childContext.path());
if (givenStory.hasAnchorParameters()) {
story = storyWithMatchingScenarios(story, givenStory.getAnchorParameters());
}
parameters.putAll(givenStory.getParameters());
run(childContext, story, parameters);
}
}
}
use of org.jbehave.core.model.Story in project jbehave-core by jbehave.
the class Embedder method mapStoriesAsPaths.
public void mapStoriesAsPaths(List<String> storyPaths) {
EmbedderControls embedderControls = embedderControls();
embedderMonitor.usingControls(embedderControls);
if (embedderControls.skip()) {
embedderMonitor.storiesSkipped(storyPaths);
return;
}
processSystemProperties();
StoryManager storyManager = storyManager();
for (String storyPath : storyPaths) {
Story story = storyManager.storyOfPath(storyPath);
embedderMonitor.mappingStory(storyPath, metaFilters());
storyMapper.map(story, new MetaFilter("", embedderMonitor));
for (String filter : metaFilters) {
storyMapper.map(story, new MetaFilter(filter, embedderMonitor));
}
}
generateMapsView(storyMapper.getStoryMaps());
}
use of org.jbehave.core.model.Story in project jbehave-core by jbehave.
the class PerformableTree method performBeforeOrAfterStories.
public void performBeforeOrAfterStories(RunContext context, Stage stage) {
String storyPath = StringUtils.capitalize(stage.name().toLowerCase()) + "Stories";
context.currentPath(storyPath);
context.reporter().beforeStory(new Story(storyPath), false);
try {
(stage == Stage.BEFORE ? root.beforeSteps : root.afterSteps).perform(context);
} catch (InterruptedException e) {
throw new UUIDExceptionWrapper(e);
} finally {
invokeDelayedReporters(context.reporter());
}
context.reporter().afterStory(false);
invokeDelayedReporters(context.reporter());
}
Aggregations