scenarioOutput.getSteps().forEach(so -> reportStep(so, issues));
}
private void reportStep(final StepOutput stepOutput, final Collection<String> issues) {
final Ansi.Color color;
final StepResult stepResult = stepOutput.getResult();
if (stepResult instanceof StepResult.Error) {
color = RED;
} else if (stepResult instanceof StepResult.Failure) {
color = YELLOW;
} else if (stepResult instanceof StepResult.Pending) {
color = CYAN;
} else if (stepResult instanceof StepResult.Skipped) {
color = MAGENTA;
} else if (stepResult instanceof StepResult.Success) {
color = GREEN;
} else {
throw new IllegalStateException("The [" + stepResult+ "] step result is not supported by the reporter");
}
try {
final Ansi stepReportOutput = ansi().fg(color).a(" " + stepOutput.getDescription()).reset().newline();
writer.append(stepReportOutput.toString());
if (stepResult instanceof StepResult.Error || stepResult instanceof StepResult.Failure) {
for (final String issue : issues) {
final String issueTrackerUrlPattern = Configuration.getConfig("issueTrackerUrlPattern", "%s");
writer.append("Issue: " + String.format(issueTrackerUrlPattern, issue) + "\n");
}
}
if (stepResult instanceof StepResult.Error) {
stepResult.getException().printStackTrace(new PrintWriter(writer, true));
}
if (stepResult instanceof StepResult.Failure) {
stepResult.getException().writeTo(writer, 3);
}
} catch (final IOException e) {
throw new IllegalStateException(e);
}