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

cucumber.runtime.AmbiguousStepDefinitionsException Maven / Gradle / Ivy

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

import gherkin.pickles.PickleStep;

import java.util.List;

public class AmbiguousStepDefinitionsException extends CucumberException {
    private final List matches;

    public AmbiguousStepDefinitionsException(PickleStep step, List matches) {
        super(createMessage(step, matches));
        this.matches = matches;
    }

    private static String createMessage(PickleStep step, List matches) {
        StringBuilder msg = new StringBuilder();
        msg.append(quoteText(step.getText())).append(" matches more than one step definition:\n");
        for (StepDefinitionMatch match : matches) {
            msg.append("  ").append(quoteText(match.getPattern())).append(" in ").append(match.getLocation()).append("\n");
        }
        return msg.toString();
    }

    private static String quoteText(String text) {
        return "\"" + text + "\"";
    }

    public List getMatches() {
        return matches;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy