Search in sources :

Example 6 with Narrative

use of org.jbehave.core.model.Narrative 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"));
}
Also used : Description(org.jbehave.core.model.Description) Narrative(org.jbehave.core.model.Narrative) Matchers.containsString(org.hamcrest.Matchers.containsString) GivenStory(org.jbehave.core.model.GivenStory) Story(org.jbehave.core.model.Story) Test(org.junit.Test)

Example 7 with Narrative

use of org.jbehave.core.model.Narrative 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"));
}
Also used : Description(org.jbehave.core.model.Description) Narrative(org.jbehave.core.model.Narrative) Matchers.containsString(org.hamcrest.Matchers.containsString) GivenStory(org.jbehave.core.model.GivenStory) Story(org.jbehave.core.model.Story) Test(org.junit.Test)

Example 8 with Narrative

use of org.jbehave.core.model.Narrative 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;
}
Also used : GivenStories(org.jbehave.core.model.GivenStories) Meta(org.jbehave.core.model.Meta) Description(org.jbehave.core.model.Description) Narrative(org.jbehave.core.model.Narrative) Lifecycle(org.jbehave.core.model.Lifecycle) Story(org.jbehave.core.model.Story) File(java.io.File) Scenario(org.jbehave.core.model.Scenario)

Example 9 with Narrative

use of org.jbehave.core.model.Narrative in project jbehave-core by jbehave.

the class GherkinStoryParserBehaviour method shouldParseStoryWithAlternativeNarrative.

@Test
public void shouldParseStoryWithAlternativeNarrative() throws IOException {
    String storyAsText = "Feature: Hello Car\n" + "Narrative:\n" + "As a car driver\n" + "I want to drive cars on 4 wheels\n" + "So that I can feel safer\n" + "Scenario: Car can drive\n" + "Given I have a car with 4 wheels\n" + "Then I can drive it.\n";
    Story story = storyParser.parseStory(storyAsText);
    assertThat(story.getDescription().asString(), equalTo("Hello Car"));
    Narrative narrative = story.getNarrative();
    assertThat(narrative.asA(), equalTo("car driver"));
    assertThat(narrative.iWantTo(), equalTo("drive cars on 4 wheels"));
    assertThat(narrative.soThat(), equalTo("I can feel safer"));
}
Also used : Narrative(org.jbehave.core.model.Narrative) Story(org.jbehave.core.model.Story) Test(org.junit.Test)

Aggregations

Narrative (org.jbehave.core.model.Narrative)9 Story (org.jbehave.core.model.Story)8 Test (org.junit.Test)6 Description (org.jbehave.core.model.Description)5 Matchers.containsString (org.hamcrest.Matchers.containsString)4 GivenStory (org.jbehave.core.model.GivenStory)4 Scenario (org.jbehave.core.model.Scenario)3 Meta (org.jbehave.core.model.Meta)2 File (java.io.File)1 Matcher (java.util.regex.Matcher)1 UUIDExceptionWrapper (org.jbehave.core.failures.UUIDExceptionWrapper)1 ExamplesTable (org.jbehave.core.model.ExamplesTable)1 GivenStories (org.jbehave.core.model.GivenStories)1 Lifecycle (org.jbehave.core.model.Lifecycle)1 OutcomesTable (org.jbehave.core.model.OutcomesTable)1 OutcomesFailed (org.jbehave.core.model.OutcomesTable.OutcomesFailed)1