Search in sources :

Example 11 with Story

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

the class RegexStoryParserBehaviour method shouldParseStoryAndProvideEmptyNameWhenPathIsNull.

@Test
public void shouldParseStoryAndProvideEmptyNameWhenPathIsNull() {
    Story story = parser.parseStory(EMPTY, null);
    assertThat(story.getPath(), equalTo(EMPTY));
    assertThat(story.getName(), equalTo(EMPTY));
}
Also used : GivenStory(org.jbehave.core.model.GivenStory) Story(org.jbehave.core.model.Story) Test(org.junit.Test)

Example 12 with Story

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

the class RegexStoryParserBehaviour method shouldParseStoryWithoutAPath.

@Test
public void shouldParseStoryWithoutAPath() {
    String wholeStory = "Given a step" + NL + "When I run it" + NL + "Then I should an output";
    Story story = parser.parseStory(wholeStory);
    assertThat(story.getPath(), equalTo(EMPTY));
    Scenario scenario = story.getScenarios().get(0);
    assertThat(scenario.getSteps(), equalTo(asList("Given a step", "When I run it", "Then I should an output")));
}
Also used : Matchers.containsString(org.hamcrest.Matchers.containsString) GivenStory(org.jbehave.core.model.GivenStory) Story(org.jbehave.core.model.Story) Scenario(org.jbehave.core.model.Scenario) Test(org.junit.Test)

Example 13 with Story

use of org.jbehave.core.model.Story 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));
}
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 14 with Story

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

the class RegexStoryParserBehaviour method parseStoryWithGivenStories.

private void parseStoryWithGivenStories(String wholeStory) {
    Story story = parser.parseStory(wholeStory, storyPath);
    Scenario scenario = story.getScenarios().get(0);
    assertThat(scenario.getGivenStories().getPaths(), equalTo(asList("path/to/one", "path/to/two")));
    assertThat(scenario.getSteps(), equalTo(asList("Given a step")));
}
Also used : GivenStory(org.jbehave.core.model.GivenStory) Story(org.jbehave.core.model.Story) Scenario(org.jbehave.core.model.Scenario)

Example 15 with Story

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

the class RegexStoryParserBehaviour method shouldParseStoryWithGivenStoriesAndExamplesCommentedOut.

@Test
public void shouldParseStoryWithGivenStoriesAndExamplesCommentedOut() {
    String wholeStory = "Scenario: Show that we can comment out GivenStories and Examples portions of a scenario" + NL + "!-- GivenStories: AGivenStoryToBeCommented" + NL + "Given a scenario Given" + NL + "When I parse it to When" + NL + "And I parse it to And" + NL + "!-- And ignore me too" + NL + "Then I should get steps Then" + NL + "!-- Examples:" + NL + "|Comment|Me|Out|" + NL + "|yes|we|can|" + NL;
    Story story = parser.parseStory(wholeStory, storyPath);
    Scenario scenario = story.getScenarios().get(0);
    assertThat(scenario.getTitle(), equalTo("Show that we can comment out GivenStories and Examples portions of a scenario"));
    assertThat(scenario.getGivenStories().getPaths(), equalTo(Arrays.<String>asList()));
    List<String> steps = scenario.getSteps();
    assertThat(steps.get(0), equalTo("!-- GivenStories: AGivenStoryToBeCommented"));
    assertThat(steps.get(1), equalTo("Given a scenario Given"));
    assertThat(steps.get(2), equalTo("When I parse it to When"));
    assertThat(steps.get(3), equalTo("And I parse it to And"));
    assertThat(steps.get(4), equalTo("!-- And ignore me too"));
    assertThat(steps.get(5), equalTo("Then I should get steps Then"));
    assertThat(steps.get(6), equalTo("!-- Examples:" + NL + "|Comment|Me|Out|" + NL + "|yes|we|can|"));
    assertThat(scenario.getExamplesTable().asString(), equalTo(EMPTY));
}
Also used : Matchers.containsString(org.hamcrest.Matchers.containsString) GivenStory(org.jbehave.core.model.GivenStory) Story(org.jbehave.core.model.Story) Scenario(org.jbehave.core.model.Scenario) Test(org.junit.Test)

Aggregations

Story (org.jbehave.core.model.Story)71 Test (org.junit.Test)58 Matchers.containsString (org.hamcrest.Matchers.containsString)41 GivenStory (org.jbehave.core.model.GivenStory)39 Scenario (org.jbehave.core.model.Scenario)29 Meta (org.jbehave.core.model.Meta)11 HashMap (java.util.HashMap)10 ByteArrayOutputStream (java.io.ByteArrayOutputStream)9 PrintStream (java.io.PrintStream)9 ArrayList (java.util.ArrayList)9 JUnitStory (org.jbehave.core.junit.JUnitStory)9 OutputStream (java.io.OutputStream)8 InjectableEmbedder (org.jbehave.core.InjectableEmbedder)8 UsingEmbedder (org.jbehave.core.annotations.UsingEmbedder)8 Configuration (org.jbehave.core.configuration.Configuration)8 MostUsefulConfiguration (org.jbehave.core.configuration.MostUsefulConfiguration)8 BatchFailures (org.jbehave.core.failures.BatchFailures)8 StoryPathResolver (org.jbehave.core.io.StoryPathResolver)8 Narrative (org.jbehave.core.model.Narrative)8 RunContext (org.jbehave.core.embedder.PerformableTree.RunContext)7