All Downloads are FREE. Search and download functionalities are using the official Maven repository.

cucumber.runtime.ScenarioResultImpl Maven / Gradle / Ivy

There is a newer version: 1.2.6
Show newest version
package cucumber.runtime;

import gherkin.formatter.Reporter;
import gherkin.formatter.model.Result;

import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;

import static java.util.Arrays.asList;

class ScenarioResultImpl implements ScenarioResult {
    private static final List SEVERITY = asList("passed", "undefined", "pending", "skipped", "failed");
    private final List stepResults = new ArrayList();
    private final Reporter reporter;

    public ScenarioResultImpl(Reporter reporter) {
        this.reporter = reporter;
    }

    void add(Result result) {
        stepResults.add(result);
    }

    @Override
    public String getStatus() {
        int pos = 0;
        for (Result stepResult : stepResults) {
            pos = Math.max(pos, SEVERITY.indexOf(stepResult.getStatus()));
        }
        return SEVERITY.get(pos);
    }

    @Override
    public boolean isFailed() {
        return "failed".equals(getStatus());
    }

    @Override
    public void embed(InputStream data, String mimeType) {
        reporter.embedding(mimeType, data);
    }

    @Override
    public void write(String text) {
        reporter.write(text);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy