use of org.jbehave.core.model.Story in project jbehave-core by jbehave.
the class NullStoryReporterBehaviour method shouldOnlyReportOverriddenMethods.
@Test
public void shouldOnlyReportOverriddenMethods() {
ByteArrayOutputStream out = new ByteArrayOutputStream();
final PrintStream printStream = new PrintStream(out);
StoryReporter reporter = new NullStoryReporter() {
@Override
public void beforeStory(Story story, boolean givenStory) {
printStream.println("beforeStory");
}
@Override
public void afterStory(boolean givenStory) {
printStream.println("afterStory");
}
};
StoryNarrator.narrateAnInterestingStory(reporter, false);
assertThat(out.toString(), Matchers.equalTo("beforeStory" + NL + "afterStory" + NL));
}
use of org.jbehave.core.model.Story in project jbehave-core by jbehave.
the class SilentSuccessFilterBehaviour method shouldNotPassSilentlyOutputNotAllowedByMetaFilter.
@Test
public void shouldNotPassSilentlyOutputNotAllowedByMetaFilter() {
// Given
Story story = new Story();
Scenario scenario = new Scenario();
String metaFilter = "";
// When
filter.storyNotAllowed(story, metaFilter);
filter.scenarioNotAllowed(scenario, metaFilter);
// Then
InOrder inOrder = inOrder(delegate);
inOrder.verify(delegate).storyNotAllowed(story, metaFilter);
inOrder.verify(delegate).scenarioNotAllowed(scenario, metaFilter);
}
use of org.jbehave.core.model.Story in project jbehave-core by jbehave.
the class MarkUnmatchedStepsAsPendingBehaviour method shouldInvokeBeforeOrAfterStoryWithParameter.
@Test
public void shouldInvokeBeforeOrAfterStoryWithParameter() throws Exception {
BeforeOrAfterStoryWithParameter steps = new BeforeOrAfterStoryWithParameter();
Story story = mock(Story.class);
when(story.getMeta()).thenReturn(beforeAndAfterMeta());
List<Step> beforeSteps = stepCollector.collectBeforeOrAfterStorySteps(asList((CandidateSteps) steps), story, Stage.BEFORE, false);
beforeSteps.get(0).perform(null);
assertThat(steps.value, equalTo("before"));
List<Step> afterSteps = stepCollector.collectBeforeOrAfterStorySteps(asList((CandidateSteps) steps), story, Stage.AFTER, false);
afterSteps.get(0).perform(null);
assertThat(steps.value, equalTo("after"));
}
use of org.jbehave.core.model.Story in project jbehave-core by jbehave.
the class MarkUnmatchedStepsAsPendingBehaviour method shouldCollectBeforeAndAfterStoryAnnotatedSteps.
@Test
public void shouldCollectBeforeAndAfterStoryAnnotatedSteps() {
// Given some candidate steps classes with before and after story
// methods
Story story = new Story();
Meta storyMeta = story.getMeta();
CandidateSteps steps1 = mock(Steps.class);
CandidateSteps steps2 = mock(Steps.class);
BeforeOrAfterStep bafStep11 = mock(BeforeOrAfterStep.class);
BeforeOrAfterStep bafStep21 = mock(BeforeOrAfterStep.class);
BeforeOrAfterStep bafStep12 = mock(BeforeOrAfterStep.class);
BeforeOrAfterStep bafStep22 = mock(BeforeOrAfterStep.class);
Step stepBefore1 = mock(Step.class);
Step stepBefore2 = mock(Step.class);
Step stepAfter1 = mock(Step.class);
Step stepAfter2 = mock(Step.class);
boolean givenStory = false;
when(bafStep11.getStage()).thenReturn(Stage.BEFORE);
when(bafStep11.createStepWith(storyMeta)).thenReturn(stepBefore1);
when(bafStep21.getStage()).thenReturn(Stage.BEFORE);
when(bafStep21.createStepWith(storyMeta)).thenReturn(stepBefore2);
when(bafStep12.getStage()).thenReturn(Stage.AFTER);
when(bafStep12.createStepWith(storyMeta)).thenReturn(stepAfter1);
when(bafStep22.getStage()).thenReturn(Stage.AFTER);
when(bafStep22.createStepWith(storyMeta)).thenReturn(stepAfter2);
when(steps1.listBeforeOrAfterStory(givenStory)).thenReturn(asList(bafStep11, bafStep12));
when(steps2.listBeforeOrAfterStory(givenStory)).thenReturn(asList(bafStep21, bafStep22));
// When we collect the list of steps
List<Step> beforeSteps = stepCollector.collectBeforeOrAfterStorySteps(asList(steps1, steps2), story, Stage.BEFORE, givenStory);
List<Step> afterSteps = stepCollector.collectBeforeOrAfterStorySteps(asList(steps1, steps2), story, Stage.AFTER, givenStory);
// Then all before and after steps should be added
assertThat(beforeSteps, equalTo(asList(stepBefore1, stepBefore2)));
assertThat(afterSteps, equalTo(asList(stepAfter1, stepAfter2)));
}
use of org.jbehave.core.model.Story in project jbehave-core by jbehave.
the class GherkinStoryParserBehaviour method shouldParseStoryWithBackground.
@Test
public void shouldParseStoryWithBackground() throws IOException {
String storyAsText = "Feature: Hello Car\n\n" + "Background:\n" + "Given I have a license\n\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"));
assertThat(story.getLifecycle().getBeforeSteps(Scope.SCENARIO), hasItem("Given I have a license"));
assertThat(story.getScenarios().get(0).getSteps().size(), equalTo(2));
}
Aggregations