Package gherkin.formatter.model

Examples of gherkin.formatter.model.Feature


        stash.tag(new Tag(tag, line));
    }

    @Override
    public void feature(String keyword, String name, String description, Integer line) {
        formatter.feature(new Feature(stash.comments, stash.tags, keyword, name, description, line, stash.featureId(name)));
        stash.reset();
    }
View Full Code Here


    @SuppressWarnings("rawtypes")
    @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);
View Full Code Here

    @SuppressWarnings("rawtypes")
    @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);
View Full Code Here

    @SuppressWarnings("rawtypes")
    @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");
View Full Code Here

    private String uri() {
        return "uri";
    }

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

    public void parse(String src) {
        List<Map> featureHashes = gson.fromJson(new StringReader(src), List.class);
        for (Map o : featureHashes) {
            formatter.uri(getString(o, "uri"));
            new Feature(comments(o), tags(o), keyword(o), name(o), description(o), line(o), id(o)).replay(formatter);
            for (Map featureElement : (List<Map>) getList(o, "elements")) {
                featureElement(featureElement).replay(formatter);
                for (Map hook : (List<Map>) getList(featureElement, "before")) {
                    before(hook);
                }
View Full Code Here

TOP

Related Classes of gherkin.formatter.model.Feature

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.