use of org.jbehave.core.model.Scenario in project jbehave-core by jbehave.
the class RegexStoryParserBehaviour method shouldParseStoryWithGivenStoriesAtStoryAndScenarioLevel.
@Test
public void shouldParseStoryWithGivenStoriesAtStoryAndScenarioLevel() {
String wholeStory = "GivenStories: GivenAPreconditionToStory" + NL + "Scenario:" + NL + "GivenStories: GivenAPreconditionToScenario" + NL + "Given a scenario Given";
Story story = parser.parseStory(wholeStory, storyPath);
assertThat(story.getGivenStories().getPaths(), equalTo(asList("GivenAPreconditionToStory")));
Scenario scenario = story.getScenarios().get(0);
assertThat(scenario.getGivenStories().getPaths(), equalTo(asList("GivenAPreconditionToScenario")));
List<String> steps = scenario.getSteps();
assertThat(steps.get(0), equalTo("Given a scenario Given"));
}
use of org.jbehave.core.model.Scenario in project jbehave-core by jbehave.
the class RegexStoryParserBehaviour method shouldParseStoryWithMetaAndLifecycle.
@Test
public void shouldParseStoryWithMetaAndLifecycle() {
String wholeStory = "Meta: @skip @theme parsing" + NL + "Lifecycle:" + NL + "Before:" + NL + "Given a step before each scenario" + NL + "And another before step" + NL + "Scenario: A scenario" + NL + "Meta: @author Mauro" + NL + "Given a step " + NL + "Scenario: Another scenario" + NL + "Meta: @author Paul" + NL + "Given another step ";
Story story = parser.parseStory(wholeStory, storyPath);
assertThat(story.getPath(), equalTo(storyPath));
Meta storyMeta = story.getMeta();
assertThat(storyMeta.getProperty("theme"), equalTo("parsing"));
assertThat(storyMeta.getProperty("skip"), equalTo(EMPTY));
assertThat(storyMeta.getProperty("unknown"), equalTo(EMPTY));
Lifecycle lifecycle = story.getLifecycle();
assertThat(lifecycle.getBeforeSteps().size(), equalTo(2));
List<Scenario> scenarios = story.getScenarios();
assertThat(scenarios.get(0).getTitle(), equalTo("A scenario"));
assertThat(scenarios.get(0).getMeta().getProperty("author"), equalTo("Mauro"));
assertThat(scenarios.get(1).getTitle(), equalTo("Another scenario"));
assertThat(scenarios.get(1).getMeta().getProperty("author"), equalTo("Paul"));
}
use of org.jbehave.core.model.Scenario in project jbehave-core by jbehave.
the class RegexStoryParserBehaviour method shouldParseStoryWithLifecycleAndMultipleScopes.
@Test
public void shouldParseStoryWithLifecycleAndMultipleScopes() {
String wholeStory = "Lifecycle: " + NL + "Before:" + NL + NL + "Scope: SCENARIO" + NL + "Given a step before each scenario" + NL + "And another before scenario" + NL + "Scope: STORY" + NL + "Given a step before each story" + NL + "And another before story" + NL + "After:" + NL + NL + "Scope: STORY" + NL + "Given a step after each story" + NL + "And another after story" + NL + "Scope: SCENARIO" + NL + "Given a step after each scenario" + NL + "And another after scenario" + NL + "Scenario:" + NL + "Given a scenario";
Story story = parser.parseStory(wholeStory, storyPath);
assertThat(story.getLifecycle().hasBeforeSteps(), is(true));
List<String> beforeStorySteps = story.getLifecycle().getBeforeSteps(Scope.STORY);
assertThat(beforeStorySteps.get(0), equalTo("Given a step before each story"));
assertThat(beforeStorySteps.get(1), equalTo("And another before story"));
List<String> beforeScenarioSteps = story.getLifecycle().getBeforeSteps(Scope.SCENARIO);
assertThat(beforeScenarioSteps.get(0), equalTo("Given a step before each scenario"));
assertThat(beforeScenarioSteps.get(1), equalTo("And another before scenario"));
assertThat(story.getLifecycle().hasAfterSteps(), is(true));
List<String> afterStorySteps = story.getLifecycle().getAfterSteps(Scope.STORY);
assertThat(afterStorySteps.get(0), equalTo("Given a step after each story"));
assertThat(afterStorySteps.get(1), equalTo("And another after story"));
List<String> afterScenarioSteps = story.getLifecycle().getAfterSteps(Scope.SCENARIO);
assertThat(afterScenarioSteps.get(0), equalTo("Given a step after each scenario"));
assertThat(afterScenarioSteps.get(1), equalTo("And another after scenario"));
Scenario scenario = story.getScenarios().get(0);
List<String> steps = scenario.getSteps();
assertThat(steps.get(0), equalTo("Given a scenario"));
}
use of org.jbehave.core.model.Scenario in project jbehave-core by jbehave.
the class RegexStoryParserBehaviour method shouldParseStoryWithLifecycleAfterOnly.
@Test
public void shouldParseStoryWithLifecycleAfterOnly() {
String wholeStory = "Lifecycle: " + NL + "After:" + NL + NL + "Given a step after each scenario" + NL + "And another after step" + NL + "Scenario:" + NL + "Given a scenario";
Story story = parser.parseStory(wholeStory, storyPath);
List<String> beforeSteps = story.getLifecycle().getBeforeSteps();
assertThat(beforeSteps.isEmpty(), equalTo(true));
List<String> afterSteps = story.getLifecycle().getAfterSteps();
assertThat(afterSteps.get(0), equalTo("Given a step after each scenario"));
assertThat(afterSteps.get(1), equalTo("And another after step"));
Scenario scenario = story.getScenarios().get(0);
List<String> steps = scenario.getSteps();
assertThat(steps.get(0), equalTo("Given a scenario"));
}
use of org.jbehave.core.model.Scenario in project jbehave-core by jbehave.
the class DelegatingStoryReporterBehaviour method shouldDelegateReporterEvents.
@Test
public void shouldDelegateReporterEvents() {
// Given
StoryReporter delegate = mock(StoryReporter.class);
DelegatingStoryReporter delegator = new DelegatingStoryReporter(delegate);
List<String> givenStoryPaths = asList("path/to/story1", "path/to/story2");
GivenStories givenStories = new GivenStories(StringUtils.join(givenStoryPaths, ","));
ExamplesTable examplesTable = new ExamplesTable("|one|two|\n|1|2|\n");
UUIDExceptionWrapper anException = new UUIDExceptionWrapper(new IllegalArgumentException());
Story story = new Story();
boolean givenStory = false;
Scenario scenario = new Scenario();
String filter = "-some property";
// When
delegator.dryRun();
delegator.beforeStory(story, givenStory);
delegator.storyNotAllowed(story, filter);
delegator.beforeScenario(scenario);
delegator.beforeScenario("My scenario 1");
delegator.scenarioNotAllowed(scenario, filter);
delegator.scenarioMeta(Meta.EMPTY);
delegator.givenStories(givenStoryPaths);
delegator.givenStories(givenStories);
delegator.successful("Given step 1.1");
delegator.ignorable("!-- Then ignore me");
delegator.comment("!-- comment");
delegator.pending("When step 1.2");
delegator.notPerformed("Then step 1.3");
delegator.beforeExamples(asList("Given step <one>", "Then step <two>"), examplesTable);
delegator.example(examplesTable.getRow(0));
delegator.afterExamples();
delegator.afterScenario();
delegator.beforeScenario("My scenario 2");
delegator.successful("Given step 2.1");
delegator.successful("When step 2.2");
delegator.failed("Then step 2.3", anException);
delegator.afterScenario();
delegator.afterStory(givenStory);
// Then
assertThat(delegator.toString(), containsString(delegate.toString()));
InOrder inOrder = inOrder(delegate);
inOrder.verify(delegate).dryRun();
inOrder.verify(delegate).beforeStory(story, givenStory);
inOrder.verify(delegate).storyNotAllowed(story, filter);
inOrder.verify(delegate).beforeScenario(scenario);
inOrder.verify(delegate).beforeScenario("My scenario 1");
inOrder.verify(delegate).scenarioNotAllowed(scenario, filter);
inOrder.verify(delegate).scenarioMeta(Meta.EMPTY);
inOrder.verify(delegate).givenStories(givenStoryPaths);
inOrder.verify(delegate).givenStories(givenStories);
inOrder.verify(delegate).successful("Given step 1.1");
inOrder.verify(delegate).ignorable("!-- Then ignore me");
inOrder.verify(delegate).comment("!-- comment");
inOrder.verify(delegate).pending("When step 1.2");
inOrder.verify(delegate).notPerformed("Then step 1.3");
inOrder.verify(delegate).beforeExamples(asList("Given step <one>", "Then step <two>"), examplesTable);
inOrder.verify(delegate).example(examplesTable.getRow(0));
inOrder.verify(delegate).afterExamples();
inOrder.verify(delegate).afterScenario();
inOrder.verify(delegate).beforeScenario("My scenario 2");
inOrder.verify(delegate).successful("Given step 2.1");
inOrder.verify(delegate).successful("When step 2.2");
inOrder.verify(delegate).failed("Then step 2.3", anException);
inOrder.verify(delegate).afterScenario();
inOrder.verify(delegate).afterStory(givenStory);
}
Aggregations