use of org.jbehave.core.model.Scenario in project serenity-jbehave by serenity-bdd.
the class JUnitDescriptionGenerator method insertDescriptionForExamples.
private void insertDescriptionForExamples(PerformableScenario performableScenario, Description scenarioDescription) {
Scenario scenario = performableScenario.getScenario();
for (ExamplePerformableScenario examplePerformableScenario : performableScenario.getExamples()) {
Description exampleRowDescription = Description.createSuiteDescription(configuration.keywords().examplesTableRow() + " " + examplePerformableScenario.getParameters());
scenarioDescription.addChild(exampleRowDescription);
if (hasGivenStories(scenario)) {
insertGivenStories(scenario, exampleRowDescription);
}
addScenarioSteps(ScenarioType.EXAMPLE, scenario, exampleRowDescription);
}
}
use of org.jbehave.core.model.Scenario in project jbehave-core by jbehave.
the class RegexStoryParserBehaviour method shouldParseLongStory.
@Test
public void shouldParseLongStory() {
String aGivenWhenThen = "Given a step" + NL + "When I run it" + NL + "Then I should seen an output" + NL;
StringBuffer aScenario = new StringBuffer();
aScenario.append("Scenario: A long scenario").append(NL);
int numberOfGivenWhenThensPerScenario = 50;
for (int i = 0; i < numberOfGivenWhenThensPerScenario; i++) {
aScenario.append(aGivenWhenThen);
}
int numberOfScenarios = 100;
StringBuffer wholeStory = new StringBuffer();
wholeStory.append("Story: A very long story").append(NL);
for (int i = 0; i < numberOfScenarios; i++) {
wholeStory.append(aScenario).append(NL);
}
Story story = parser.parseStory(wholeStory.toString(), null);
assertThat(story.getScenarios().size(), equalTo(numberOfScenarios));
for (Scenario scenario : story.getScenarios()) {
assertThat(scenario.getSteps().size(), equalTo(numberOfGivenWhenThensPerScenario * 3));
}
}
use of org.jbehave.core.model.Scenario in project jbehave-core by jbehave.
the class RegexStoryParserBehaviour method shouldParseStoryWithLifecycleAfterUponOutcome.
@Test
public void shouldParseStoryWithLifecycleAfterUponOutcome() {
String wholeStory = "Lifecycle: " + NL + "After:" + NL + NL + "Outcome: ANY " + NL + "Given a step after any scenario" + NL + "Outcome: SUCCESS " + NL + "Given a step after successful scenario" + NL + "Outcome: FAILURE " + 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(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"));
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 shouldParseStoryWithMetaAndNarrative.
@Test
public void shouldParseStoryWithMetaAndNarrative() {
String wholeStory = "Meta: @skip @theme parsing" + NL + "Narrative: This bit of text is ignored" + NL + "In order to renovate my house" + NL + "As a customer" + NL + "I want to get a loan" + 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));
Narrative narrative = story.getNarrative();
assertThat(narrative.isEmpty(), not(true));
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 shouldParseStoryWithLifecycleBeforeOnly.
@Test
public void shouldParseStoryWithLifecycleBeforeOnly() {
String wholeStory = "Lifecycle: " + NL + "Before:" + NL + NL + "Given a step before each scenario" + NL + "And another before step" + NL + "Scenario:" + NL + "Given a scenario";
Story story = parser.parseStory(wholeStory, storyPath);
List<String> beforeSteps = story.getLifecycle().getBeforeSteps();
assertThat(beforeSteps.get(0), equalTo("Given a step before each scenario"));
assertThat(beforeSteps.get(1), equalTo("And another before step"));
List<String> afterSteps = story.getLifecycle().getAfterSteps();
assertThat(afterSteps.isEmpty(), equalTo(true));
Scenario scenario = story.getScenarios().get(0);
List<String> steps = scenario.getSteps();
assertThat(steps.get(0), equalTo("Given a scenario"));
}
Aggregations