use of org.jbehave.core.failures.UUIDExceptionWrapper in project jbehave-core by jbehave.
the class SilentSuccessFilterBehaviour method shouldPassSilentlyOutputFromSuccessfulScenarios.
@Test
public void shouldPassSilentlyOutputFromSuccessfulScenarios() {
// Given
ExamplesTable examplesTable = new ExamplesTable("|one|two|\n|1|2|\n");
UUIDExceptionWrapper anException = new UUIDExceptionWrapper(new IllegalArgumentException());
Story story = new Story();
GivenStories givenStories = new GivenStories("path/to/story1,path/to/story2");
List<String> givenStoryPaths = asList("path/to/story1", "path/to/story2");
// When
Scenario scenario1 = new Scenario("My scenario 1", Meta.EMPTY);
filter.dryRun();
filter.beforeStory(story, false);
filter.beforeScenario(scenario1);
filter.scenarioMeta(Meta.EMPTY);
filter.successful("Given step 1.1");
filter.ignorable("!-- Then ignore me");
filter.comment("!-- A comment");
filter.successful("When step 1.2");
filter.successful("Then step 1.3");
filter.afterScenario();
Scenario scenario2 = new Scenario("My scenario 2", Meta.EMPTY);
filter.beforeScenario(scenario2);
filter.givenStories(givenStories);
filter.givenStories(givenStoryPaths);
filter.successful("Given step 2.1");
filter.pending("When step 2.2");
filter.notPerformed("Then step 2.3");
filter.afterScenario();
Scenario scenario3 = new Scenario("My scenario 3", Meta.EMPTY);
filter.beforeScenario(scenario3);
filter.beforeExamples(asList("Given step <one>", "Then step <two>"), examplesTable);
Map<String, String> tableRow = new HashMap<>();
filter.example(tableRow);
filter.successful("Given step 3.1");
filter.successful("When step 3.2");
filter.ignorable("!-- Then ignore me too");
filter.comment("!-- One more comment");
filter.failed("Then step 3.3", anException);
OutcomesTable outcomesTable = new OutcomesTable();
filter.failedOutcomes("When failed outcomes", outcomesTable);
filter.afterExamples();
filter.afterScenario();
Scenario scenario4 = new Scenario("My scenario 4", Meta.EMPTY);
filter.beforeScenario(scenario4);
filter.successful("Given step 4.1");
filter.successful("When step 4.2");
filter.successful("Then step 4.3");
filter.afterScenario();
filter.afterStory(false);
// Then
InOrder inOrder = inOrder(delegate);
// Scenarios 1 and 4 are successful
verify(delegate, never()).beforeScenario(scenario1);
verify(delegate, never()).successful("Given step 1.1");
verify(delegate, never()).ignorable("!-- Then ignore me");
verify(delegate, never()).comment("!-- A comment");
verify(delegate, never()).successful("When step 1.2");
verify(delegate, never()).successful("Then step 1.3");
verify(delegate, never()).beforeScenario(scenario4);
verify(delegate, never()).successful("Given step 4.1");
verify(delegate, never()).successful("When step 4.2");
verify(delegate, never()).successful("Then step 4.3");
// Scenarios 2 and 3 have pending or failed steps
inOrder.verify(delegate).dryRun();
inOrder.verify(delegate).beforeStory(story, false);
inOrder.verify(delegate).beforeScenario(scenario2);
inOrder.verify(delegate).givenStories(givenStories);
inOrder.verify(delegate).givenStories(givenStoryPaths);
inOrder.verify(delegate).successful("Given step 2.1");
inOrder.verify(delegate).pending("When step 2.2");
inOrder.verify(delegate).notPerformed("Then step 2.3");
inOrder.verify(delegate).afterScenario();
inOrder.verify(delegate).beforeScenario(scenario3);
inOrder.verify(delegate).beforeExamples(asList("Given step <one>", "Then step <two>"), examplesTable);
inOrder.verify(delegate).example(tableRow);
inOrder.verify(delegate).successful("Given step 3.1");
inOrder.verify(delegate).successful("When step 3.2");
inOrder.verify(delegate).ignorable("!-- Then ignore me too");
inOrder.verify(delegate).comment("!-- One more comment");
inOrder.verify(delegate).failed("Then step 3.3", anException);
inOrder.verify(delegate).failedOutcomes("When failed outcomes", outcomesTable);
inOrder.verify(delegate).afterExamples();
inOrder.verify(delegate).afterScenario();
inOrder.verify(delegate).afterStory(false);
}
use of org.jbehave.core.failures.UUIDExceptionWrapper in project jbehave-core by jbehave.
the class SilentSuccessFilterBehaviour method shouldPassSilentlyOutputFromSuccessfulScenariosWithDeprecatedBeforeScenario.
@Test
public void shouldPassSilentlyOutputFromSuccessfulScenariosWithDeprecatedBeforeScenario() {
// Given
ExamplesTable examplesTable = new ExamplesTable("|one|two|\n|1|2|\n");
UUIDExceptionWrapper anException = new UUIDExceptionWrapper(new IllegalArgumentException());
Story story = new Story();
GivenStories givenStories = new GivenStories("path/to/story1,path/to/story2");
List<String> givenStoryPaths = asList("path/to/story1", "path/to/story2");
// When
filter.dryRun();
filter.beforeStory(story, false);
filter.beforeScenario("My scenario 1");
filter.scenarioMeta(Meta.EMPTY);
filter.successful("Given step 1.1");
filter.ignorable("!-- Then ignore me");
filter.comment("!-- A comment");
filter.successful("When step 1.2");
filter.successful("Then step 1.3");
filter.afterScenario();
filter.beforeScenario("My scenario 2");
filter.givenStories(givenStories);
filter.givenStories(givenStoryPaths);
filter.successful("Given step 2.1");
filter.pending("When step 2.2");
filter.notPerformed("Then step 2.3");
filter.afterScenario();
filter.beforeScenario("My scenario 3");
filter.beforeExamples(asList("Given step <one>", "Then step <two>"), examplesTable);
Map<String, String> tableRow = new HashMap<>();
filter.example(tableRow);
filter.successful("Given step 3.1");
filter.successful("When step 3.2");
filter.ignorable("!-- Then ignore me too");
filter.comment("!-- One more comment");
filter.failed("Then step 3.3", anException);
OutcomesTable outcomesTable = new OutcomesTable();
filter.failedOutcomes("When failed outcomes", outcomesTable);
filter.afterExamples();
filter.afterScenario();
filter.beforeScenario("My scenario 4");
filter.successful("Given step 4.1");
filter.successful("When step 4.2");
filter.successful("Then step 4.3");
filter.afterScenario();
filter.afterStory(false);
// Then
InOrder inOrder = inOrder(delegate);
// Scenarios 1 and 4 are successful
verify(delegate, never()).beforeScenario("My scenario 1");
verify(delegate, never()).successful("Given step 1.1");
verify(delegate, never()).ignorable("!-- Then ignore me");
verify(delegate, never()).comment("!-- A comment");
verify(delegate, never()).successful("When step 1.2");
verify(delegate, never()).successful("Then step 1.3");
verify(delegate, never()).beforeScenario("My scenario 4");
verify(delegate, never()).successful("Given step 4.1");
verify(delegate, never()).successful("When step 4.2");
verify(delegate, never()).successful("Then step 4.3");
// Scenarios 2 and 3 have pending or failed steps
inOrder.verify(delegate).dryRun();
inOrder.verify(delegate).beforeStory(story, false);
inOrder.verify(delegate).beforeScenario("My scenario 2");
inOrder.verify(delegate).givenStories(givenStories);
inOrder.verify(delegate).givenStories(givenStoryPaths);
inOrder.verify(delegate).successful("Given step 2.1");
inOrder.verify(delegate).pending("When step 2.2");
inOrder.verify(delegate).notPerformed("Then step 2.3");
inOrder.verify(delegate).afterScenario();
inOrder.verify(delegate).beforeScenario("My scenario 3");
inOrder.verify(delegate).beforeExamples(asList("Given step <one>", "Then step <two>"), examplesTable);
inOrder.verify(delegate).example(tableRow);
inOrder.verify(delegate).successful("Given step 3.1");
inOrder.verify(delegate).successful("When step 3.2");
inOrder.verify(delegate).ignorable("!-- Then ignore me too");
inOrder.verify(delegate).comment("!-- One more comment");
inOrder.verify(delegate).failed("Then step 3.3", anException);
inOrder.verify(delegate).failedOutcomes("When failed outcomes", outcomesTable);
inOrder.verify(delegate).afterExamples();
inOrder.verify(delegate).afterScenario();
inOrder.verify(delegate).afterStory(false);
}
use of org.jbehave.core.failures.UUIDExceptionWrapper in project jbehave-core by jbehave.
the class StepResultBehaviour method shouldDescribeResultToReporterWithParameterValuesWhenAvailable.
@Test
public void shouldDescribeResultToReporterWithParameterValuesWhenAvailable() {
// Given
StoryReporter reporter = mock(StoryReporter.class);
// When
String successful = "Given that a step is pending or failing";
successful("Given that a step is $pending or $failing").withParameterValues(successful).describeTo(reporter);
String pending = "When a step is performed";
pending("When a step is $performed").withParameterValues(pending).describeTo(reporter);
String notPerformed = "Then the step should describe itself properly to reporters";
notPerformed("Then the step should $describe itself properly to reporters").withParameterValues(notPerformed).describeTo(reporter);
String failed = "And any errors should appear at the end of the story";
UUIDExceptionWrapper cause = new UUIDExceptionWrapper(new IllegalStateException());
failed("And any errors should $appear at the end of the story", cause).withParameterValues(failed).describeTo(reporter);
// Then
verify(reporter).successful(successful);
verify(reporter).pending(pending);
verify(reporter).notPerformed(notPerformed);
verify(reporter).failed(failed, cause);
}
use of org.jbehave.core.failures.UUIDExceptionWrapper in project jbehave-core by jbehave.
the class StepsBehaviour method shouldProvideStepsToBeNotPerformedAfterScenarioUponOutcome.
@Test
public void shouldProvideStepsToBeNotPerformedAfterScenarioUponOutcome() {
MultipleAliasesSteps steps = new MultipleAliasesSteps();
ScenarioType scenarioType = ScenarioType.NORMAL;
List<BeforeOrAfterStep> beforeAfterScenario = steps.listBeforeOrAfterScenario(scenarioType);
assertThat(beforeAfterScenario.size(), equalTo(4));
beforeAfterScenario.get(0).createStep().doNotPerform(null);
assertThat(steps.beforeNormalScenario, is(true));
Meta storyAndScenarioMeta = null;
UUIDExceptionWrapper failure = new UUIDExceptionWrapper();
// uponOutcome=ANY
beforeAfterScenario.get(1).createStepUponOutcome(storyAndScenarioMeta).doNotPerform(failure);
assertThat(steps.afterNormalScenario, is(true));
// uponOutcome=SUCCESS
beforeAfterScenario.get(2).createStepUponOutcome(storyAndScenarioMeta).doNotPerform(failure);
assertThat(steps.afterSuccessfulScenario, is(false));
// uponOutcome=FAILURE
beforeAfterScenario.get(3).createStepUponOutcome(storyAndScenarioMeta).doNotPerform(failure);
assertThat(steps.afterFailedScenario, is(true));
}
use of org.jbehave.core.failures.UUIDExceptionWrapper in project jbehave-core by jbehave.
the class MarkUnmatchedStepsAsPendingBehaviour method shouldInvokeBeforeOrAfterStoryWithParameterAndException.
@Test
public void shouldInvokeBeforeOrAfterStoryWithParameterAndException() throws Exception {
BeforeOrAfterStoryWithParameterAndExceptionSteps steps = new BeforeOrAfterStoryWithParameterAndExceptionSteps();
Story story = mock(Story.class);
when(story.getMeta()).thenReturn(beforeAndAfterMeta());
List<Step> beforeSteps = stepCollector.collectBeforeOrAfterStorySteps(asList((CandidateSteps) steps), story, Stage.BEFORE, false);
UUIDExceptionWrapper failureOccurred = new UUIDExceptionWrapper();
beforeSteps.get(0).doNotPerform(failureOccurred);
assertThat(steps.value, equalTo("before"));
assertThat(steps.exception, equalTo(failureOccurred));
List<Step> afterSteps = stepCollector.collectBeforeOrAfterStorySteps(asList((CandidateSteps) steps), story, Stage.AFTER, false);
failureOccurred = new UUIDExceptionWrapper();
afterSteps.get(0).doNotPerform(failureOccurred);
assertThat(steps.value, equalTo("after"));
assertThat(steps.exception, equalTo(failureOccurred));
}
Aggregations