Package org.jbehave.core.model

Examples of org.jbehave.core.model.Lifecycle


                "Scenario:"+ NL +       
                "Given a scenario";
        Story story = parser.parseStory(wholeStory, storyPath);
        List<String> beforeSteps = story.getLifecycle().getBeforeSteps();
        assertThat(beforeSteps.isEmpty(), equalTo(true));
        Lifecycle lifecycle = story.getLifecycle();
    List<String> afterSteps = lifecycle.getAfterSteps();
        assertThat(afterSteps.get(0), equalTo("Given a step after any scenario"));
        assertThat(afterSteps.get(1), equalTo("Given a step after successful scenario"));
        assertThat(afterSteps.get(2), equalTo("Given a step after failed scenario"));
        assertThat(lifecycle.getAfterSteps(Outcome.ANY).size(), equalTo(1));
        assertThat(lifecycle.getAfterSteps(Outcome.ANY).get(0), equalTo("Given a step after any scenario"));
        assertThat(lifecycle.getAfterSteps(Outcome.SUCCESS).size(), equalTo(1));
        assertThat(lifecycle.getAfterSteps(Outcome.SUCCESS).get(0), equalTo("Given a step after successful scenario"));
        assertThat(lifecycle.getAfterSteps(Outcome.FAILURE).size(), equalTo(1));
        assertThat(lifecycle.getAfterSteps(Outcome.FAILURE).get(0), equalTo("Given a step after failed scenario"));
        Scenario scenario = story.getScenarios().get(0);
        List<String> steps = scenario.getSteps();
        assertThat(steps.get(0), equalTo("Given a scenario"));
    }
View Full Code Here


                "Wenn ein Kunde 20 T-Shirts bestellt";
      parser = new RegexStoryParser(new LocalizedKeywords(Locale.GERMAN));
        Story story = parser.parseStory(wholeStory, storyPath);
        List<String> beforeSteps = story.getLifecycle().getBeforeSteps();
        assertThat(beforeSteps.isEmpty(), equalTo(true));
        Lifecycle lifecycle = story.getLifecycle();
    List<String> afterSteps = lifecycle.getAfterSteps();
        assertThat(afterSteps.get(0), equalTo("Gegeben im Lager sind 200 T-Shirts"));
        assertThat(afterSteps.get(1), equalTo("Gegeben im Lager sind 300 T-Shirts"));
        assertThat(afterSteps.get(2), equalTo("Gegeben im Lager sind 400 T-Shirts"));
        assertThat(lifecycle.getAfterSteps(Outcome.ANY).size(), equalTo(1));
        assertThat(lifecycle.getAfterSteps(Outcome.ANY).get(0), equalTo("Gegeben im Lager sind 200 T-Shirts"));
        assertThat(lifecycle.getAfterSteps(Outcome.SUCCESS).size(), equalTo(1));
        assertThat(lifecycle.getAfterSteps(Outcome.SUCCESS).get(0), equalTo("Gegeben im Lager sind 300 T-Shirts"));
        assertThat(lifecycle.getAfterSteps(Outcome.FAILURE).size(), equalTo(1));
        assertThat(lifecycle.getAfterSteps(Outcome.FAILURE).get(0), equalTo("Gegeben im Lager sind 400 T-Shirts"));
        Scenario scenario = story.getScenarios().get(0);
        List<String> steps = scenario.getSteps();
        assertThat(steps.get(0), equalTo("Wenn ein Kunde 20 T-Shirts bestellt"));
    }
View Full Code Here

    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());
        }
View Full Code Here

        if ( findingBeforeAndAfter.matches() ){
            String beforeLifecycle = findingBeforeAndAfter.group(1).trim();
      Steps beforeSteps = parseBeforeLifecycle(beforeLifecycle);
            String afterLifecycle = findingBeforeAndAfter.group(2).trim();
      Steps[] afterSteps = parseAfterLifecycle(afterLifecycle);
            return new Lifecycle(beforeSteps, afterSteps);
        }
        Matcher findingBefore = compile(".*" + keywords.before() + "(.*)\\s*", DOTALL).matcher(lifecycle);
        if ( findingBefore.matches() ){
            String beforeLifecycle = findingBefore.group(1).trim();
      Steps beforeSteps = parseBeforeLifecycle(beforeLifecycle);
            return new Lifecycle(beforeSteps, new Steps(new ArrayList<String>()));
        }
        Matcher findingAfter = compile(".*" + keywords.after() + "(.*)\\s*", DOTALL).matcher(lifecycle);
        if ( findingAfter.matches() ){
            Steps beforeSteps = Steps.EMPTY;
            String afterLifecycle = findingAfter.group(1).trim();
      Steps[] afterSteps = parseAfterLifecycle(afterLifecycle);
            return new Lifecycle(beforeSteps, afterSteps);
        }
        return Lifecycle.EMPTY;
    }
View Full Code Here

        when(successCandidate.isAndStep(myFailureStep)).thenReturn(false);
        when(successCandidate.createMatchedStepUponOutcome(myFailureStep, parameters, Outcome.FAILURE)).thenReturn(failureStep);

        when(steps.listCandidates()).thenReturn(asList(anyCandidate, successCandidate, failureCandidate));

    Lifecycle lifecycle = new Lifecycle(
        org.jbehave.core.model.Lifecycle.Steps.EMPTY,
        new org.jbehave.core.model.Lifecycle.Steps(Outcome.ANY, asList(myAnyStep)),
        new org.jbehave.core.model.Lifecycle.Steps(Outcome.SUCCESS, asList(mySuccessStep)),
        new org.jbehave.core.model.Lifecycle.Steps(Outcome.FAILURE, asList(myFailureStep)));
View Full Code Here

TOP

Related Classes of org.jbehave.core.model.Lifecycle

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.