Class TestNGPrettyFormatter

  • All Implemented Interfaces:
    io.cucumber.plugin.ColorAware, io.cucumber.plugin.ConcurrentEventListener, io.cucumber.plugin.Plugin

    public class TestNGPrettyFormatter
    extends Object
    implements io.cucumber.plugin.ConcurrentEventListener, io.cucumber.plugin.ColorAware
    This class is responsible for printing the steps/features/scenarios to console. This is a custom implementation of the cucumber PrettyFormatter that allows more flexibility with colors and other formatting options. Error messages generated from other classes are printed using the standard log4j.

    This class implements a set of eventListeners for the tests suite. This methods are fired before/after specific events during tests execution. Since the library uses testng and not junit to run the test ConcurrentEventListener should be used instead of EventListener

    There are several reasons to implement a custom formatter in Gingerspec: * Unlike PrettyFormatter, this formatter also prints things like Docstrings and Datatables * Instead of printing the whole stacktrace of the error when an assertion fails, only the main message of the assertion is printed, which makes tests easier to read (this can be overridden by using -DSHOW_ERRORS_STACKTRACE) * If the variable -DSHOW_STACK_INFO is present, the formatter will print the step definition location and arguments * Print comments written on top of steps (#log) and even do variable replacement on them * Last but not least, this formatter also makes variable replacement, so it will correctly print Gingerspec custom variables (!{VAR}, #{VAR}, ${VAR} and @{VAR})

    Author:
    Jose Fernandez
    • Constructor Detail

      • TestNGPrettyFormatter

        public TestNGPrettyFormatter​(OutputStream out)
    • Method Detail

      • setEventPublisher

        public void setEventPublisher​(io.cucumber.plugin.event.EventPublisher publisher)
        Specified by:
        setEventPublisher in interface io.cucumber.plugin.ConcurrentEventListener
      • setMonochrome

        public void setMonochrome​(boolean monochrome)
        Specified by:
        setMonochrome in interface io.cucumber.plugin.ColorAware