use of org.jbehave.core.model.Story in project jbehave-core by jbehave.
the class RegexStoryParserBehaviour method shouldParseStoryWithAlternativeNarrative.
@Test
public void shouldParseStoryWithAlternativeNarrative() {
String wholeStory = "Story: This is free-text description" + NL + "Narrative: This is an alternative narrative" + NL + "As a customer" + NL + "I want to get a loan" + NL + "So that I can renovate my house" + NL + "Scenario: A first scenario";
Story story = parser.parseStory(wholeStory, storyPath);
Description description = story.getDescription();
assertThat(description.asString(), equalTo("Story: This is free-text description"));
Narrative narrative = story.getNarrative();
assertThat(narrative.isEmpty(), not(true));
assertThat(narrative.asA().toString(), equalTo("customer"));
assertThat(narrative.iWantTo().toString(), equalTo("get a loan"));
assertThat(narrative.soThat().toString(), equalTo("I can renovate my house"));
}
use of org.jbehave.core.model.Story in project jbehave-core by jbehave.
the class RegexStoryParserBehaviour method shouldParseStoryWithLifecycleAndStoryScope.
@Test
public void shouldParseStoryWithLifecycleAndStoryScope() {
String wholeStory = "Lifecycle: " + NL + "Before:" + NL + 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 + "Scenario:" + NL + "Given a scenario";
Story story = parser.parseStory(wholeStory, storyPath);
assertThat(story.getLifecycle().hasBeforeSteps(), is(true));
List<String> beforeSteps = story.getLifecycle().getBeforeSteps(Scope.STORY);
assertThat(beforeSteps.get(0), equalTo("Given a step before each story"));
assertThat(beforeSteps.get(1), equalTo("And another before story"));
assertThat(story.getLifecycle().getBeforeSteps(Scope.SCENARIO).size(), equalTo(0));
assertThat(story.getLifecycle().hasAfterSteps(), is(true));
List<String> afterSteps = story.getLifecycle().getAfterSteps(Scope.STORY);
assertThat(afterSteps.get(0), equalTo("Given a step after each story"));
assertThat(afterSteps.get(1), equalTo("And another after story"));
assertThat(story.getLifecycle().getAfterSteps(Scope.SCENARIO).size(), equalTo(0));
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.Story in project jbehave-core by jbehave.
the class RegexStoryParserBehaviour method shouldAllowSpacesInMetaProperties.
@Test
public void shouldAllowSpacesInMetaProperties() {
String wholeStory = "Meta: @ theme parsing @ skip" + NL + "Scenario: " + NL + "Meta: @authors Mauro Paul" + NL + "Given a scenario " + NL + "When I parse it" + NL + "Then I should get steps";
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(story.getScenarios().get(0).getMeta().getProperty("authors"), equalTo("Mauro Paul"));
}
use of org.jbehave.core.model.Story in project jbehave-core by jbehave.
the class RegexStoryParserBehaviour method shouldParseStoryWithScenarioContainingExamplesTable.
@Test
public void shouldParseStoryWithScenarioContainingExamplesTable() {
String wholeStory = "Scenario: A scenario with examples table" + NL + NL + "Given a step with a <one>" + NL + "When I run the scenario of name <two>" + NL + "Then I should see <three> in the output" + NL + "Examples:" + NL + "|one|two|three|" + NL + "|11|12|13|" + NL + "|21|22|23|" + NL;
Story story = parser.parseStory(wholeStory, storyPath);
Scenario scenario = story.getScenarios().get(0);
assertThat(scenario.getTitle(), equalTo("A scenario with examples table"));
assertThat(scenario.getGivenStories().getPaths().size(), equalTo(0));
assertThat(scenario.getSteps(), equalTo(asList("Given a step with a <one>", "When I run the scenario of name <two>", "Then I should see <three> in the output")));
ExamplesTable table = scenario.getExamplesTable();
assertThat(table.asString(), equalTo("|one|two|three|" + NL + "|11|12|13|" + NL + "|21|22|23|" + NL));
assertThat(table.getRowCount(), equalTo(2));
assertThat(table.getRow(0), not(nullValue()));
assertThat(table.getRow(0).get("one"), equalTo("11"));
assertThat(table.getRow(0).get("two"), equalTo("12"));
assertThat(table.getRow(0).get("three"), equalTo("13"));
assertThat(table.getRow(1), not(nullValue()));
assertThat(table.getRow(1).get("one"), equalTo("21"));
assertThat(table.getRow(1).get("two"), equalTo("22"));
assertThat(table.getRow(1).get("three"), equalTo("23"));
}
use of org.jbehave.core.model.Story in project jbehave-core by jbehave.
the class RegexStoryParserBehaviour method shouldParseStoryWithLifecycleAfterUponOutcomeAndMetaFilter.
@Test
public void shouldParseStoryWithLifecycleAfterUponOutcomeAndMetaFilter() {
String wholeStory = "Lifecycle: " + NL + "After:" + NL + NL + "Outcome: ANY " + NL + "MetaFilter: +all" + NL + "Given a step after any scenario" + NL + "Outcome: SUCCESS " + NL + "MetaFilter: +happy" + NL + "Given a step after successful scenario" + NL + "Outcome: FAILURE " + NL + "MetaFilter: +sad" + NL + "Given a step after failed scenario" + NL + "Scenario:" + NL + "Given a scenario";
Story story = parser.parseStory(wholeStory, storyPath);
List<String> beforeSteps = story.getLifecycle().getBeforeSteps();
assertThat(beforeSteps.isEmpty(), equalTo(true));
Lifecycle lifecycle = story.getLifecycle();
List<String> afterSteps = lifecycle.getAfterSteps();
assertThat(afterSteps.get(0), equalTo("Given a step after any scenario"));
assertThat(afterSteps.get(1), equalTo("Given a step after successful scenario"));
assertThat(afterSteps.get(2), equalTo("Given a step after failed scenario"));
assertThat(new ArrayList<>(lifecycle.getOutcomes()), equalTo(Arrays.asList(Outcome.ANY, Outcome.SUCCESS, Outcome.FAILURE)));
assertThat(lifecycle.getAfterSteps(Outcome.ANY).size(), equalTo(1));
assertThat(lifecycle.getAfterSteps(Outcome.ANY).get(0), equalTo("Given a step after any scenario"));
assertThat(lifecycle.getAfterSteps(Outcome.SUCCESS).size(), equalTo(1));
assertThat(lifecycle.getAfterSteps(Outcome.SUCCESS).get(0), equalTo("Given a step after successful scenario"));
assertThat(lifecycle.getAfterSteps(Outcome.FAILURE).size(), equalTo(1));
assertThat(lifecycle.getAfterSteps(Outcome.FAILURE).get(0), equalTo("Given a step after failed scenario"));
assertThat(lifecycle.getMetaFilter(Outcome.ANY).asString(), equalTo("+all"));
Keywords keywords = new Keywords();
assertThat(lifecycle.getAfterSteps(Outcome.ANY, Meta.createMeta("@all", keywords)).size(), equalTo(1));
assertThat(lifecycle.getAfterSteps(Outcome.ANY, Meta.createMeta("@all", keywords)).get(0), equalTo("Given a step after any scenario"));
assertThat(lifecycle.getAfterSteps(Outcome.ANY, Meta.createMeta("@none", keywords)).size(), equalTo(0));
assertThat(lifecycle.getMetaFilter(Outcome.SUCCESS).asString(), equalTo("+happy"));
assertThat(lifecycle.getAfterSteps(Outcome.SUCCESS, Meta.createMeta("@happy", keywords)).size(), equalTo(1));
assertThat(lifecycle.getAfterSteps(Outcome.SUCCESS, Meta.createMeta("@happy", keywords)).get(0), equalTo("Given a step after successful scenario"));
assertThat(lifecycle.getAfterSteps(Outcome.SUCCESS, Meta.createMeta("@none", keywords)).size(), equalTo(0));
assertThat(lifecycle.getMetaFilter(Outcome.FAILURE).asString(), equalTo("+sad"));
assertThat(lifecycle.getAfterSteps(Outcome.FAILURE, Meta.createMeta("@sad", keywords)).size(), equalTo(1));
assertThat(lifecycle.getAfterSteps(Outcome.FAILURE, Meta.createMeta("@sad", keywords)).get(0), equalTo("Given a step after failed scenario"));
assertThat(lifecycle.getAfterSteps(Outcome.FAILURE, Meta.createMeta("@none", keywords)).size(), equalTo(0));
Scenario scenario = story.getScenarios().get(0);
List<String> steps = scenario.getSteps();
assertThat(steps.get(0), equalTo("Given a scenario"));
}
Aggregations