Skip to content

Implement basic ConsoleCode module for colored console output #1

@zhangsu

Description

@zhangsu

Currently all our text output onto the console are in the console's default color:
screen shot 2015-06-21 at 3 59 16 pm
We would like have the ability to output colored output. In particular, we want tests that pass to be output as green and failures to be red.

For example, In the top half of the screenshot where a ProgressFormatter is used, the character F should be output as red whereas the character . should be marked green. The whole paragraph including and after Failures: should also be in red. In the bottom half of the screenshot, the failure line 1 + 1 = 2 (FAILED) should be marked red.

This can be done through ANSI escape sequences for colors:
https://en.wikipedia.org/wiki/ANSI_escape_code#Colors

In a way similar to how RSpec did it with a ConsoleCode module under formatters:
https://github.com/rspec/rspec-core/blob/master/lib/rspec/core/formatters/console_codes.rb

  • create a very basic ConsoleCode module that has a mapping between color codes and enums such as SUCCESS and FAILURE.
  • Modify ProgressFormatter to output successful test output as green and failure as red.
  • Ditto for DocumentationFormatter.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions