Search in sources :

Example 31 with Meta

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

the class PerformableTree method performableStory.

private PerformableStory performableStory(RunContext context, Story story, Map<String, String> storyParameters) {
    PerformableStory performableStory = new PerformableStory(story, context.configuration().keywords(), context.givenStory());
    // determine if story is allowed
    boolean storyAllowed = true;
    FilteredStory filteredStory = context.filter(story);
    Meta storyMeta = story.getMeta();
    if (!filteredStory.allowed()) {
        storyAllowed = false;
    }
    performableStory.allowed(storyAllowed);
    if (storyAllowed) {
        performableStory.addBeforeSteps(context.beforeOrAfterStorySteps(story, Stage.BEFORE));
        performableStory.addBeforeSteps(context.lifecycleSteps(story.getLifecycle(), storyMeta, Stage.BEFORE, Scope.STORY));
        // determine if before and after scenario steps should be run
        boolean runBeforeAndAfterScenarioSteps = shouldRunBeforeOrAfterScenarioSteps(context);
        for (Scenario scenario : story.getScenarios()) {
            Map<String, String> scenarioParameters = new HashMap<>(storyParameters);
            PerformableScenario performableScenario = performableScenario(context, story, scenarioParameters, filteredStory, storyMeta, runBeforeAndAfterScenarioSteps, scenario);
            if (performableScenario.hasNormalScenario() || performableScenario.hasExamples()) {
                performableStory.add(performableScenario);
            }
        }
        // Add Given stories only if story contains scenarios
        if (!performableStory.getScenarios().isEmpty()) {
            Map<String, String> givenStoryParameters = new HashMap<>(storyParameters);
            addMetaParameters(givenStoryParameters, storyMeta);
            if (story.hasGivenStories()) {
                performableStory.addGivenStories(performableGivenStories(context, story.getGivenStories(), givenStoryParameters));
            }
        }
        performableStory.addAfterSteps(context.lifecycleSteps(story.getLifecycle(), storyMeta, Stage.AFTER, Scope.STORY));
        performableStory.addAfterSteps(context.beforeOrAfterStorySteps(story, Stage.AFTER));
    }
    return performableStory;
}
Also used : Meta(org.jbehave.core.model.Meta) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Scenario(org.jbehave.core.model.Scenario)

Example 32 with Meta

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

the class PerformableTree method parameterMeta.

private Meta parameterMeta(RunContext context, Map<String, String> parameters) {
    Meta meta = Meta.EMPTY;
    Keywords keywords = context.configuration().keywords();
    String metaText = keywords.meta();
    if (parameters.containsKey(metaText)) {
        meta = Meta.createMeta(parameters.get(metaText), keywords);
    }
    return meta;
}
Also used : Meta(org.jbehave.core.model.Meta) Keywords(org.jbehave.core.configuration.Keywords)

Aggregations

Meta (org.jbehave.core.model.Meta)32 Test (org.junit.Test)23 Story (org.jbehave.core.model.Story)11 Scenario (org.jbehave.core.model.Scenario)9 Matchers.containsString (org.hamcrest.Matchers.containsString)8 HashMap (java.util.HashMap)6 Properties (java.util.Properties)6 GivenStory (org.jbehave.core.model.GivenStory)6 RegexStepMatcher (org.jbehave.core.parsers.RegexStepMatcher)6 StepMatcher (org.jbehave.core.parsers.StepMatcher)6 Silent (org.jbehave.core.steps.AbstractStepResult.Silent)6 ParametrisedStep (org.jbehave.core.steps.StepCreator.ParametrisedStep)6 Map (java.util.Map)4 PendingStep (org.jbehave.core.steps.StepCreator.PendingStep)4 Matchers.anyString (org.mockito.Matchers.anyString)4 ScenarioType (org.jbehave.core.annotations.ScenarioType)3 ExamplesTable (org.jbehave.core.model.ExamplesTable)3 Lifecycle (org.jbehave.core.model.Lifecycle)3 BytecodeReadingParanamer (com.thoughtworks.paranamer.BytecodeReadingParanamer)2 CachingParanamer (com.thoughtworks.paranamer.CachingParanamer)2