Configuration configuration = configuration();
List<CandidateSteps> candidateSteps = candidateSteps();
storyRunner.runBeforeOrAfterStories(configuration, candidateSteps, Stage.BEFORE);
BatchFailures batchFailures = new BatchFailures();
buildReporters(configuration, storyPaths);
for (String storyPath : storyPaths) {
try {
embedderMonitor.runningStory(storyPath);
Story story = storyRunner.storyOfPath(configuration, storyPath);
storyRunner.run(configuration, candidateSteps, story);
} catch (Throwable e) {
if (embedderControls.batch()) {
// collect and postpone decision to throw exception
batchFailures.put(storyPath, e);
} else {
if (embedderControls.ignoreFailureInStories()) {
embedderMonitor.storyFailed(storyPath, e);
} else {
throw new RunningStoriesFailed(storyPath, e);
}
}
}
}
storyRunner.runBeforeOrAfterStories(configuration, candidateSteps, Stage.AFTER);
if (embedderControls.batch() && batchFailures.size() > 0) {
if (embedderControls.ignoreFailureInStories()) {
embedderMonitor.batchFailed(batchFailures);
} else {
throw new RunningStoriesFailed(batchFailures);
}