gherkin.formatter
Class PrettyFormatter

java.lang.Object
  extended by gherkin.formatter.PrettyFormatter
All Implemented Interfaces:
Formatter, Reporter, Closeable

public class PrettyFormatter
extends Object
implements Reporter, Formatter

This class pretty prints feature files like they were in the source, only prettier. That is, with consistent indentation. This class is also a Reporter, which means it can be used to print execution results - highlighting arguments, printing source information and exception information.


Constructor Summary
PrettyFormatter(Appendable out, boolean monochrome, boolean executing)
           
 
Method Summary
 void after(Match match, Result result)
           
 void background(Background background)
          Called before the actual execution of the background step container.
 void before(Match match, Result result)
           
 void close()
          Closes all underlying streams.
 void docString(DocString docString)
           
 void done()
          Indicates that the last file has been processed.
 void embedding(String mimeType, byte[] data)
           
 void endOfScenarioLifeCycle(Scenario scenario)
          Is called at the end of the scenario life cycle, meaning after the last "after" hook.
 void eof()
          Indicates the End-Of-File for a Gherkin document (.feature file)
 void examples(Examples examples)
          Called before the actual execution of the scenario examples.
 void feature(Feature feature)
          Called after the Formatter.uri(String), but before the actual feature execution.
 void match(Match match)
           
 void nextRow()
           
 void result(Result result)
           
 void row(List<CellResult> cellResults)
           
 void scenario(Scenario scenario)
          Called before the actual execution of the scenario step container.
 void scenarioOutline(ScenarioOutline scenarioOutline)
          Called before the actual execution of the scenario outline step container.
 void setMonochrome(boolean monochrome)
           
 void startOfScenarioLifeCycle(Scenario scenario)
          Is called at the beginning of the scenario life cycle, meaning before the first "before" hook.
 void step(Step step)
          Is called for each step of a step container.
 void syntaxError(String state, String event, List<String> legalEvents, String uri, Integer line)
          Is called in case any syntax error was detected during the parsing of the feature files.
 void table(List<? extends Row> rows)
           
 void uri(String uri)
          Called at the beginning of each feature.
 void write(String text)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PrettyFormatter

public PrettyFormatter(Appendable out,
                       boolean monochrome,
                       boolean executing)
Method Detail

setMonochrome

public void setMonochrome(boolean monochrome)

uri

public void uri(String uri)
Description copied from interface: Formatter
Called at the beginning of each feature.

Specified by:
uri in interface Formatter
Parameters:
uri - the feature's URI

feature

public void feature(Feature feature)
Description copied from interface: Formatter
Called after the Formatter.uri(String), but before the actual feature execution.

Specified by:
feature in interface Formatter
Parameters:
feature - the to be executed Feature

background

public void background(Background background)
Description copied from interface: Formatter
Called before the actual execution of the background step container.

Specified by:
background in interface Formatter
Parameters:
background - the to be executed Background

scenario

public void scenario(Scenario scenario)
Description copied from interface: Formatter
Called before the actual execution of the scenario step container.

Specified by:
scenario in interface Formatter
Parameters:
scenario - the to be executed Scenario

scenarioOutline

public void scenarioOutline(ScenarioOutline scenarioOutline)
Description copied from interface: Formatter
Called before the actual execution of the scenario outline step container.

Specified by:
scenarioOutline in interface Formatter
Parameters:
scenarioOutline - the to be executed ScenarioOutline

startOfScenarioLifeCycle

public void startOfScenarioLifeCycle(Scenario scenario)
Description copied from interface: Formatter
Is called at the beginning of the scenario life cycle, meaning before the first "before" hook.

Specified by:
startOfScenarioLifeCycle in interface Formatter
Parameters:
scenario - the Scenario of the current lifecycle

endOfScenarioLifeCycle

public void endOfScenarioLifeCycle(Scenario scenario)
Description copied from interface: Formatter
Is called at the end of the scenario life cycle, meaning after the last "after" hook. * @param scenario the Scenario of the current lifecycle

Specified by:
endOfScenarioLifeCycle in interface Formatter

examples

public void examples(Examples examples)
Description copied from interface: Formatter
Called before the actual execution of the scenario examples. This is called after the Formatter.scenarioOutline(gherkin.formatter.model.ScenarioOutline), but before any actual scenario example.

Specified by:
examples in interface Formatter
Parameters:
examples - the to be executed

step

public void step(Step step)
Description copied from interface: Formatter
Is called for each step of a step container. Attention: All steps are iterated through this method before any step is actually executed.

Specified by:
step in interface Formatter
Parameters:
step - the Step to be executed

match

public void match(Match match)
Specified by:
match in interface Reporter

embedding

public void embedding(String mimeType,
                      byte[] data)
Specified by:
embedding in interface Reporter

write

public void write(String text)
Specified by:
write in interface Reporter

result

public void result(Result result)
Specified by:
result in interface Reporter

before

public void before(Match match,
                   Result result)
Specified by:
before in interface Reporter

after

public void after(Match match,
                  Result result)
Specified by:
after in interface Reporter

table

public void table(List<? extends Row> rows)

row

public void row(List<CellResult> cellResults)

nextRow

public void nextRow()

syntaxError

public void syntaxError(String state,
                        String event,
                        List<String> legalEvents,
                        String uri,
                        Integer line)
Description copied from interface: Formatter
Is called in case any syntax error was detected during the parsing of the feature files.

Specified by:
syntaxError in interface Formatter
Parameters:
state - the current state of the parser machine
event - detected event
legalEvents - expected event
uri - the URI of the feature file
line - the line number of the event

done

public void done()
Description copied from interface: Formatter
Indicates that the last file has been processed. This should print out any closing output, such as completing the JSON string, but it should *not* close any underlying streams/writers.

Specified by:
done in interface Formatter

close

public void close()
Description copied from interface: Formatter
Closes all underlying streams.

Specified by:
close in interface Formatter
Specified by:
close in interface Closeable

docString

public void docString(DocString docString)

eof

public void eof()
Description copied from interface: Formatter
Indicates the End-Of-File for a Gherkin document (.feature file)

Specified by:
eof in interface Formatter


Copyright © 2013. All rights reserved.