Skip to content

Commit

Permalink
Set the serenity.console.colors property to true to get ANSI colors i…
Browse files Browse the repository at this point in the history
…n the console output (don't use on Jenkins).
  • Loading branch information
wakaleo committed Nov 19, 2015
1 parent 213548e commit 552172c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,8 @@ public enum ThucydidesSystemProperty {
*/
THUCYDIDES_CONSOLE_HEADINGS,

THUCYDIDES_CONSOLE_COLORS,

/**
* If set to true, Asciidoc formatting will be supported in the narrative texts.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,20 @@ public class ConsoleLoggingListener implements StepListener {
public static final String ANSI_PURPLE = "\u001B[95m";
public static final String ANSI_CYAN = "\u001B[96m";

public static final String SERENITY_BIG_BANNER = ANSI_CYAN +
public static final String SERENITY_BIG_BANNER =
"\n\n-------------------------------------------------------------------------------------\n" +
" _______. _______ .______ _______ .__ __. __ .___________.____ ____ \n" +
" / || ____|| _ \\ | ____|| \\ | | | | | |\\ \\ / / \n" +
" | (----`| |__ | |_) | | |__ | \\| | | | `---| |----` \\ \\/ / \n" +
" \\ \\ | __| | / | __| | . ` | | | | | \\_ _/ \n" +
".----) | | |____ | |\\ \\----.| |____ | |\\ | | | | | | | \n" +
"|_______/ |_______|| _| `._____||_______||__| \\__| |__| |__| |__| \n" +
"-------------------------------------------------------------------------------------\n"
+ ANSI_RESET;
public static final String SERENITY_SMALL_BANNER = ANSI_BLUE + "\n--------------\n" +
"-------------------------------------------------------------------------------------\n";

public static final String SERENITY_SMALL_BANNER = "\n--------------\n" +
"- SERENITY -\n" +
"--------------" + ANSI_RESET;
"--------------";

// STAR WARS
private static final List<String> BANNER_HEADINGS = ImmutableList.of(
SERENITY_SMALL_BANNER,
Expand Down Expand Up @@ -194,7 +195,7 @@ private void logBanner() {
}

private String bannerHeading() {
return BANNER_HEADINGS.get(headingStyle);
return cyan(BANNER_HEADINGS.get(headingStyle));
}

private boolean loggingLevelIsAtLeast(LoggingLevel minimumLoggingLevel) {
Expand Down Expand Up @@ -463,24 +464,28 @@ public void assumptionViolated(String message) {
}
}

private boolean showColoredOutput() {
return ThucydidesSystemProperty.THUCYDIDES_CONSOLE_COLORS.booleanFrom(environmentVariables,false);
}

private String red(String text) {
return ANSI_RED + text + ANSI_RESET;
return (showColoredOutput()) ? ANSI_RED + text + ANSI_RESET : text;
}

private String green(String text) {
return ANSI_GREEN + text + ANSI_RESET;
return (showColoredOutput()) ? ANSI_GREEN + text + ANSI_RESET : text;
}

private String yellow(String text) {
return ANSI_YELLOW + text + ANSI_RESET;
return (showColoredOutput()) ? ANSI_YELLOW + text + ANSI_RESET : text;
}

private String cyan(String text) {
return ANSI_CYAN + text + ANSI_RESET;
return (showColoredOutput()) ? ANSI_CYAN + text + ANSI_RESET : text;
}

private String purple(String text) {
return ANSI_PURPLE + text + ANSI_RESET;
return (showColoredOutput()) ? ANSI_PURPLE + text + ANSI_RESET : text;
}

}

0 comments on commit 552172c

Please sign in to comment.