if (line.startsWith("Scenario")) {
if (scenarioBuilder == null) {
scenarioBuilder = new StringBuilder(line);
parseDescription = true;
} else {
throw new MByHaveException("This scenario contains two scenario descriptions.");
}
} else if (line.startsWith("Given") || line.startsWith("When") || line.startsWith("Then")) {
if (parseDescription) {
scenarioDescription = scenarioBuilder.toString();
scenarioBuilder = new StringBuilder(line);
parseDescription = false;
} else if (scenarioBuilder != null) {
steps.add(scenarioBuilder.toString());
scenarioBuilder = new StringBuilder(line);
} else {
scenarioDescription = "Scenario"; //Default scenario description
scenarioBuilder = new StringBuilder(line);
}
} else if (scenarioBuilder != null) {
scenarioBuilder.append(line + "\n");
}
}
if (scenarioBuilder != null) {
if (parseDescription) {
throw new MByHaveException("The scenario description does not contain any step description"); //TODO get the scenario description from somewhere.
}
steps.add(scenarioBuilder.toString());
}
return new Scenario(scenarioDescription, steps);
}