use of org.jbehave.core.model.Description in project jbehave-core by jbehave.
the class RegexStoryParserBehaviour method shouldParseStoryWithIncompleteNarrative.
@Test
public void shouldParseStoryWithIncompleteNarrative() {
String wholeStory = "Story: This is free-text description" + NL + "Narrative: This is an incomplete narrative" + NL + "In order to renovate my house" + NL + "As a customer" + 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(), is(true));
}
use of org.jbehave.core.model.Description in project jbehave-core by jbehave.
the class PostStoryStatisticsCollectorBehaviour method narrateAnInterestingStory.
private void narrateAnInterestingStory() {
Story story = new Story("/path/to/story", new Description("An interesting story"), new Narrative("renovate my house", "customer", "get a loan"), new ArrayList<Scenario>());
reporter.dryRun();
// begin story
reporter.beforeStory(story, false);
// 1st scenario
reporter.beforeScenario(new Scenario("I ask for a loan", Meta.EMPTY));
reporter.givenStories(asList("path/to/story1", "path/to/story2"));
// 1st given story
reporter.beforeStory(story, true);
reporter.beforeScenario(new Scenario("a scenario without steps", Meta.EMPTY));
reporter.afterScenario();
reporter.afterStory(true);
// 2nd given story
reporter.beforeStory(story, true);
reporter.beforeScenario(new Scenario("the bank has $300 to loan", Meta.EMPTY));
reporter.givenStories(asList("path/to/nested/story1"));
reporter.beforeStory(story, true);
reporter.beforeScenario(new Scenario("initialise static", Meta.EMPTY));
reporter.successful("the bank has customers");
reporter.afterScenario();
reporter.afterStory(true);
reporter.afterScenario();
reporter.afterStory(true);
reporter.successful("Given I have a balance of $50");
reporter.ignorable("!-- Then ignore me");
reporter.comment("!-- A comment");
reporter.successful("When I request $20");
reporter.successful("When I ask Liz for a loan of $100");
reporter.afterScenario();
// 2nd scenario
reporter.beforeScenario(new Scenario("A failing scenario", Meta.EMPTY));
OutcomesTable outcomesTable = new OutcomesTable();
outcomesTable.addOutcome("I don't return all", 100.0, equalTo(50.));
try {
outcomesTable.verify();
} catch (UUIDExceptionWrapper e) {
reporter.failedOutcomes("Then I don't return loan", ((OutcomesFailed) e.getCause()).outcomesTable());
}
reporter.notPerformed("Then I should have $20");
ExamplesTable table = new ExamplesTable("|money|to|\n|$30|Mauro|\n|$50|Paul|\n");
reporter.beforeExamples(asList("Given money <money>", "Then I give it to <to>"), table);
reporter.example(table.getRow(0));
reporter.example(table.getRow(1));
reporter.afterExamples();
reporter.afterScenario();
// 3rd scenario
reporter.beforeScenario(new Scenario("A pending scenario", Meta.EMPTY));
reporter.pending("When I have some money");
reporter.notPerformed("Then I should have $20");
reporter.afterScenario();
// end story
reporter.afterStory(false);
}
use of org.jbehave.core.model.Description 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.Description in project jbehave-core by jbehave.
the class RegexStoryParserBehaviour method shouldParseStoryWithDescriptionAndNarrative.
@Test
public void shouldParseStoryWithDescriptionAndNarrative() {
String wholeStory = "Story: This is free-text description" + 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 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.inOrderTo().toString(), equalTo("renovate my house"));
assertThat(narrative.asA().toString(), equalTo("customer"));
assertThat(narrative.iWantTo().toString(), equalTo("get a loan"));
}
use of org.jbehave.core.model.Description in project jbehave-core by jbehave.
the class RegexStoryParser method parseStory.
public Story parseStory(String storyAsText, String storyPath) {
Description description = parseDescriptionFrom(storyAsText);
Meta meta = parseStoryMetaFrom(storyAsText);
Narrative narrative = parseNarrativeFrom(storyAsText);
GivenStories givenStories = parseGivenStories(storyAsText);
Lifecycle lifecycle = parseLifecycle(storyAsText);
List<Scenario> scenarios = parseScenariosFrom(storyAsText);
Story story = new Story(storyPath, description, meta, narrative, givenStories, lifecycle, scenarios);
if (storyPath != null) {
story.namedAs(new File(storyPath).getName());
}
return story;
}
Aggregations