Is there a way to create a custom cucumber formatter that prints the Given, When and Then steps

861 views Asked by At

I am trying to create a customer cucumber formatter and found this: http://www.relishapp.com/cucumber/cucumber/docs/extending-cucumber/custom-formatter

I noticed the documentation provided an example that only showed how to print the "Feature" name and "Scenario" name.

I am trying to also print the Given, When, and Then steps. Can someone provide me an example of that?

1

There are 1 answers

0
Jeff Price On

A good example of this is to use cucumbers own included formatters as examples.

https://github.com/cucumber/cucumber/tree/master/lib/cucumber/formatter

Take a look at the "pretty" formatter. It likely has most of what you need.

Of particular interest to your question are the methods:

  • before_step
  • before_step_result
  • step_name