Search in sources :

Example 21 with UUIDExceptionWrapper

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));
}
Also used : OutcomesFailed(org.jbehave.core.model.OutcomesTable.OutcomesFailed) UUIDExceptionWrapper(org.jbehave.core.failures.UUIDExceptionWrapper) Test(org.junit.Test)

Example 22 with UUIDExceptionWrapper

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));
}
Also used : Meta(org.jbehave.core.model.Meta) PendingStep(org.jbehave.core.steps.StepCreator.PendingStep) UUIDExceptionWrapper(org.jbehave.core.failures.UUIDExceptionWrapper) Test(org.junit.Test)

Example 23 with UUIDExceptionWrapper

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());
}
Also used : GivenStory(org.jbehave.core.model.GivenStory) Story(org.jbehave.core.model.Story) UUIDExceptionWrapper(org.jbehave.core.failures.UUIDExceptionWrapper)

Example 24 with UUIDExceptionWrapper

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());
        }
    }
}
Also used : UUIDExceptionWrapper(org.jbehave.core.failures.UUIDExceptionWrapper)

Aggregations

UUIDExceptionWrapper (org.jbehave.core.failures.UUIDExceptionWrapper)24 Test (org.junit.Test)18 LocalizedKeywords (org.jbehave.core.i18n.LocalizedKeywords)7 Story (org.jbehave.core.model.Story)7 Properties (java.util.Properties)5 OutcomesTable (org.jbehave.core.model.OutcomesTable)5 OutcomesFailed (org.jbehave.core.model.OutcomesTable.OutcomesFailed)5 ExamplesTable (org.jbehave.core.model.ExamplesTable)4 Meta (org.jbehave.core.model.Meta)4 Scenario (org.jbehave.core.model.Scenario)4 Matchers.containsString (org.hamcrest.Matchers.containsString)3 GivenStories (org.jbehave.core.model.GivenStories)3 InOrder (org.mockito.InOrder)3 Date (java.util.Date)2 HashMap (java.util.HashMap)2 LoadFromClasspath (org.jbehave.core.io.LoadFromClasspath)2 GivenStory (org.jbehave.core.model.GivenStory)2 TableTransformers (org.jbehave.core.model.TableTransformers)2 RegexStepMatcher (org.jbehave.core.parsers.RegexStepMatcher)2 StepMatcher (org.jbehave.core.parsers.StepMatcher)2