Search in sources :

Example 6 with GivenStories

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

the class RegexStoryParser method parseGivenStories.

private GivenStories parseGivenStories(String storyAsText) {
    String scenarioKeyword = keywords.scenario();
    // use text before scenario keyword, if found
    String beforeScenario = "";
    if (StringUtils.contains(storyAsText, scenarioKeyword)) {
        beforeScenario = StringUtils.substringBefore(storyAsText, scenarioKeyword);
    }
    Matcher findingGivenStories = findingStoryGivenStories().matcher(beforeScenario);
    String givenStories = findingGivenStories.find() ? findingGivenStories.group(1).trim() : NONE;
    return new GivenStories(givenStories);
}
Also used : GivenStories(org.jbehave.core.model.GivenStories) Matcher(java.util.regex.Matcher)

Example 7 with GivenStories

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

the class RegexStoryParser method parseScenario.

private Scenario parseScenario(String scenarioAsText) {
    String title = findScenarioTitle(scenarioAsText);
    String scenarioWithoutKeyword = removeStart(scenarioAsText, keywords.scenario()).trim();
    String scenarioWithoutTitle = removeStart(scenarioWithoutKeyword, title);
    scenarioWithoutTitle = startingWithNL(scenarioWithoutTitle);
    Meta meta = findScenarioMeta(scenarioWithoutTitle);
    ExamplesTable examplesTable = findExamplesTable(scenarioWithoutTitle);
    GivenStories givenStories = findScenarioGivenStories(scenarioWithoutTitle);
    if (givenStories.requireParameters()) {
        givenStories.useExamplesTable(examplesTable);
    }
    List<String> steps = findSteps(scenarioWithoutTitle);
    return new Scenario(title, meta, givenStories, examplesTable, steps);
}
Also used : GivenStories(org.jbehave.core.model.GivenStories) Meta(org.jbehave.core.model.Meta) ExamplesTable(org.jbehave.core.model.ExamplesTable) Scenario(org.jbehave.core.model.Scenario)

Example 8 with GivenStories

use of org.jbehave.core.model.GivenStories 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)

Aggregations

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