use of org.jbehave.core.model.Story 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.Story 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.Story in project jbehave-core by jbehave.
the class RegexStoryParserBehaviour method shouldParseStoryAndProvideNameFromPath.
@Test
public void shouldParseStoryAndProvideNameFromPath() {
Story story = parser.parseStory(EMPTY, storyPath);
assertThat(story.getPath(), equalTo(storyPath));
assertThat(story.getName(), equalTo(new File(storyPath).getName()));
}
use of org.jbehave.core.model.Story 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.Story in project jbehave-core by jbehave.
the class RegexStoryParserBehaviour method shouldParseStoryWithGivenStoriesWithAnchorParameters.
@Test
public void shouldParseStoryWithGivenStoriesWithAnchorParameters() {
String wholeStory = "GivenStories: path1#{id1:scenario1;id2:scenario2}" + NL + "Scenario: A scenario" + NL + "Given a step";
Story story = parser.parseStory(wholeStory, storyPath);
assertThat(story.getPath(), equalTo(storyPath));
assertThat(story.getGivenStories().getStories().size(), equalTo(1));
GivenStory givenStory = story.getGivenStories().getStories().get(0);
assertThat(givenStory.hasAnchorParameters(), equalTo(true));
Map<String, String> anchorParameters = givenStory.getAnchorParameters();
assertThat(anchorParameters.size(), equalTo(2));
assertThat(anchorParameters.get("id1"), equalTo("scenario1"));
assertThat(anchorParameters.get("id2"), equalTo("scenario2"));
}
Aggregations