Package gherkin.formatter.model

Examples of gherkin.formatter.model.Scenario


    }

    @Override
    public void scenario(String keyword, String name, String description, Integer line) {
        replayStepsOrExamples();
        formatter.scenario(new Scenario(stash.comments, stash.tags, keyword, name, description, line, stash.featureElementId(name)));
        stash.reset();
    }
View Full Code Here


    @Test
    public void testAllStepsFirstOrderingOfCalls() {
        StringBuilder stringBuilder = new StringBuilder();
        JSONFormatter jsonFormatter = new JSONPrettyFormatter(stringBuilder);
        Feature feature = feature("Test Feature");
        Scenario scenario = scenario("Test Scenario");
        Step step1 = step("Given", "Step 1");
        Step step2 = step("Given", "Step 2");
        final byte[] data1 = new byte[] {1, 2, 3};
        String text1 = "text1";
        String text2 = "text2";
        final byte[] data2 = new byte[] {4};
        Result step1Result = result("passed");
        Result step2Result = result("failed");

        jsonFormatter.uri(uri());
        jsonFormatter.feature(feature);
        jsonFormatter.startOfScenarioLifeCycle(scenario);
        jsonFormatter.before(match(), result("passed"));
        jsonFormatter.scenario(scenario);

        jsonFormatter.step(step1);
        jsonFormatter.step(step2);

        jsonFormatter.match(match());
        jsonFormatter.embedding("mime-type", data1);
        jsonFormatter.write(text1);
        jsonFormatter.result(step1Result);

        jsonFormatter.match(match());
        jsonFormatter.write(text2);
        jsonFormatter.embedding("mime-type-2", data2);
        jsonFormatter.result(step2Result);
        jsonFormatter.endOfScenarioLifeCycle(scenario);

        jsonFormatter.eof();
        jsonFormatter.done();
        jsonFormatter.close();

        Gson gson = new Gson();
        List result = gson.fromJson(stringBuilder.toString(), List.class);

        Map featureJson = (Map) result.get(0);
        assertEquals(feature.getName(), featureJson.get("name"));

        Map scenarioJson = (Map) ((List) featureJson.get("elements")).get(0);
        assertEquals(scenario.getName(), scenarioJson.get("name"));

        Map step1Json = (Map) ((List)scenarioJson.get("steps")).get(0);
        assertJsonStepData(step1, step1Result, step1Json);

        Map step2Json = (Map) ((List)scenarioJson.get("steps")).get(1);
View Full Code Here

    @Test
    public void testOneStepAtTheTimeOrderingOfCalls() {
        StringBuilder stringBuilder = new StringBuilder();
        JSONFormatter jsonFormatter = new JSONPrettyFormatter(stringBuilder);
        Feature feature = feature("Test Feature");
        Scenario scenario = scenario("Test Scenario");
        Step step1 = step("Given", "Step 1");
        Step step2 = step("Given", "Step 2");
        final byte[] data1 = new byte[] {1, 2, 3};
        String text1 = "text1";
        String text2 = "text2";
        final byte[] data2 = new byte[] {4};
        Result step1Result = result("passed");
        Result step2Result = result("failed");

        jsonFormatter.uri(uri());
        jsonFormatter.feature(feature);
        jsonFormatter.startOfScenarioLifeCycle(scenario);
        jsonFormatter.before(match(), result("passed"));
        jsonFormatter.scenario(scenario);

        jsonFormatter.step(step1);
        jsonFormatter.match(match());
        jsonFormatter.embedding("mime-type", data1);
        jsonFormatter.write(text1);
        jsonFormatter.result(step1Result);

        jsonFormatter.step(step2);
        jsonFormatter.match(match());
        jsonFormatter.write(text2);
        jsonFormatter.embedding("mime-type-2", data2);
        jsonFormatter.result(step2Result);
        jsonFormatter.endOfScenarioLifeCycle(scenario);

        jsonFormatter.eof();
        jsonFormatter.done();
        jsonFormatter.close();

        Gson gson = new Gson();
        List result = gson.fromJson(stringBuilder.toString(), List.class);

        Map featureJson = (Map) result.get(0);
        assertEquals(feature.getName(), featureJson.get("name"));

        Map scenarioJson = (Map) ((List) featureJson.get("elements")).get(0);
        assertEquals(scenario.getName(), scenarioJson.get("name"));

        Map step1Json = (Map) ((List)scenarioJson.get("steps")).get(0);
        assertJsonStepData(step1, step1Result, step1Json);

        Map step2Json = (Map) ((List)scenarioJson.get("steps")).get(1);
View Full Code Here

    @Test
    public void testBeforeHooks() {
        StringBuilder stringBuilder = new StringBuilder();
        JSONFormatter jsonFormatter = new JSONPrettyFormatter(stringBuilder);
        Feature feature = feature("Test Feature");
        Scenario scenario1 = scenario("Test Scenario 1");
        Scenario scenario2 = scenario("Test Scenario 2");

        jsonFormatter.uri(uri());
        jsonFormatter.feature(feature);

        jsonFormatter.startOfScenarioLifeCycle(scenario1);
        jsonFormatter.before(match(), result("passed"));
        jsonFormatter.scenario(scenario1);
        jsonFormatter.endOfScenarioLifeCycle(scenario1);

        jsonFormatter.startOfScenarioLifeCycle(scenario2);
        jsonFormatter.before(match(), result("passed"));
        jsonFormatter.scenario(scenario2);
        jsonFormatter.endOfScenarioLifeCycle(scenario2);

        jsonFormatter.eof();
        jsonFormatter.done();
        jsonFormatter.close();

        Gson gson = new Gson();
        List result = gson.fromJson(stringBuilder.toString(), List.class);

        Map featureJson = (Map) result.get(0);
        assertEquals(feature.getName(), featureJson.get("name"));

        Map scenarioJson = (Map) ((List) featureJson.get("elements")).get(0);
        assertEquals(scenario1.getName(), scenarioJson.get("name"));

        List beforeHooks = (List) scenarioJson.get("before");
        assertEquals(1, beforeHooks.size());

        scenarioJson = (Map) ((List) featureJson.get("elements")).get(1);
        assertEquals(scenario2.getName(), scenarioJson.get("name"));

        beforeHooks = (List) scenarioJson.get("before");
        assertEquals(1, beforeHooks.size());
    }
View Full Code Here

    private Feature feature(String featureName) {
        return new Feature(Collections.<Comment>emptyList(), Collections.<Tag>emptyList(), "", featureName, "", 12, "");
    }

    private Scenario scenario(String scenarioName) {
      return new Scenario(Collections.<Comment>emptyList(), Collections.<Tag>emptyList(), "", scenarioName, "", 13, "");
    }
View Full Code Here

    private BasicStatement featureElement(Map o) {
        String type = (String) o.get("type");
        if (type.equals("background")) {
            return new Background(comments(o), keyword(o), name(o), description(o), line(o));
        } else if (type.equals("scenario")) {
            return new Scenario(comments(o), tags(o), keyword(o), name(o), description(o), line(o), id(o));
        } else if (type.equals("scenario_outline")) {
            return new ScenarioOutline(comments(o), tags(o), keyword(o), name(o), description(o), line(o), id(o));
        } else {
            return null;
        }
View Full Code Here

TOP

Related Classes of gherkin.formatter.model.Scenario

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.