use of org.jbehave.core.failures.UUIDExceptionWrapper in project jbehave-core by jbehave.
the class StepCandidateBehaviour method shouldCaptureOutcomeFailures.
@Test
public void shouldCaptureOutcomeFailures() {
FailingSteps steps = new FailingSteps();
List<StepCandidate> candidates = steps.listCandidates();
assertThat(candidates.size(), equalTo(1));
String stepAsString = "When outcome fails for Bar upon verification";
StepResult stepResult = candidates.get(0).createMatchedStep(stepAsString, namedParameters).perform(null);
UUIDExceptionWrapper failure = stepResult.getFailure();
assertThat(failure.getCause(), instanceOf(OutcomesFailed.class));
assertThat(failure.getMessage(), equalTo(stepAsString));
}
use of org.jbehave.core.failures.UUIDExceptionWrapper in project jbehave-core by jbehave.
the class MarkUnmatchedStepsAsPendingBehaviour method shouldInvokeBeforeOrAfterScenarioWithParameterAndException.
@Test
public void shouldInvokeBeforeOrAfterScenarioWithParameterAndException() throws Exception {
BeforeOrAfterScenarioWithParameterAndExceptionSteps steps = new BeforeOrAfterScenarioWithParameterAndExceptionSteps();
Meta meta = beforeAndAfterMeta();
UUIDExceptionWrapper failureOccurred = new UUIDExceptionWrapper();
ScenarioType scenarioType = ScenarioType.NORMAL;
List<Step> beforeSteps = stepCollector.collectBeforeOrAfterScenarioSteps(asList((CandidateSteps) steps), meta, Stage.BEFORE, scenarioType);
beforeSteps.get(0).doNotPerform(failureOccurred);
assertThat(steps.value, equalTo("before"));
assertThat(steps.exception, equalTo(failureOccurred));
List<Step> afterSteps = stepCollector.collectBeforeOrAfterScenarioSteps(asList((CandidateSteps) steps), meta, Stage.AFTER, scenarioType);
failureOccurred = new UUIDExceptionWrapper();
afterSteps.get(0).doNotPerform(failureOccurred);
assertThat(steps.value, equalTo("after"));
assertThat(steps.exception, equalTo(failureOccurred));
}
use of org.jbehave.core.failures.UUIDExceptionWrapper 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());
}
use of org.jbehave.core.failures.UUIDExceptionWrapper in project jbehave-core by jbehave.
the class PerformableTree method perform.
public void perform(RunContext context, Story story) {
boolean restartingStory = false;
try {
performCancellable(context, story);
if (context.restartStory()) {
context.reporter().restartedStory(story, context.failure(context.state()));
restartingStory = true;
perform(context, story);
}
} catch (InterruptedException e) {
if (context.isCancelled(story)) {
context.reporter().storyCancelled(story, context.storyDuration(story));
context.reporter().afterStory(context.givenStory);
}
throw new UUIDExceptionWrapper(e);
} finally {
if (!context.givenStory() && !restartingStory) {
invokeDelayedReporters(context.reporter());
}
}
}
Aggregations