How to generate a HTML report using cucumber?

21,752 views
Skip to first unread message

damon

unread,
Feb 23, 2012, 2:52:59 AM2/23/12
to Cukes
Hi All

I am new to cucumber.
I am learning Automated Testing recently using cucumber + watir -
webdriver + ruby.
I have finished a demo.
But I need to know how to generate a HTML report now. That is mean it
can output a file which is xxx.html, and we can check it through
browser.

Somebody said just add "format = html" to my code.
But when I input "cucumber features --format = html", it just show
html code in the terminal.

Who can help me?
Thank you very much.

aslak hellesoy

unread,
Feb 23, 2012, 3:39:05 AM2/23/12
to cu...@googlegroups.com

Try this:

cucumber features --format html --out reports

For more info:

cucumber --help

Aslak


> Who can help me?
> Thank you very much.
>

> --
> You received this message because you are subscribed to the Google Groups "Cukes" group.
> To post to this group, send email to cu...@googlegroups.com.
> To unsubscribe from this group, send email to cukes+un...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/cukes?hl=en.
>

pavan r

unread,
Feb 23, 2012, 3:40:55 AM2/23/12
to cu...@googlegroups.com
hi damon below is the command i know

cucumber <featurename>.feature --format html --out report.html --format pretty

thanks
Pavan


--
You received this message because you are subscribed to the Google Groups "Cukes" group.
To post to this group, send email to cu...@googlegroups.com.
To unsubscribe from this group, send email to cukes+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/cukes?hl=en.




--
              --
Thanks & Regards
Pavan Kumar Reddy
Email: Pavan...@gmail.com  



Zifeng Chen

unread,
Feb 23, 2012, 7:48:01 PM2/23/12
to cu...@googlegroups.com
Hi Aslak,

Thanks a lot.
It works for me.


Damon

2012/2/23 aslak hellesoy <aslak.h...@gmail.com>

Zifeng Chen

unread,
Feb 23, 2012, 7:50:05 PM2/23/12
to cu...@googlegroups.com
Hi Pavan

Thank you very much.
I get what I want.


Damon

2012/2/23 pavan r <pavan...@gmail.com>

Tim Walker

unread,
Feb 23, 2012, 7:59:28 PM2/23/12
to cu...@googlegroups.com
Is there a way to get inner-steps (steps that call steps) to show up in these reports? 

Thanks,

Tim

Andrew Premdas

unread,
Feb 24, 2012, 5:11:13 AM2/24/12
to cu...@googlegroups.com
On 24 February 2012 00:59, Tim Walker <walk...@gmail.com> wrote:
Is there a way to get inner-steps (steps that call steps) to show up in these reports? 

Thanks,

Tim


<sign_uo>

DON'T NEST STEPS

</sign_down>



--
------------------------
Andrew Premdas

Tim Walker

unread,
Feb 24, 2012, 8:07:50 PM2/24/12
to cu...@googlegroups.com
Hi Andrew, 

Thank you for this response. Unfortunately the reuse of steps to build common sequences, to DRY up and to communicate clearly the intent of the sequence (without having to think!) has urged me towards this recommended best practice. 

http://blog.mattwynne.net/2008/11/14/dry-up-your-cucumber-steps/ 

As a Cucumber user 
I'd like an option to see nested steps indented in the output formats 
So that I can build detail report and extend the utility of Cucumber as living documentation

Any way to do that?

Thanks again, 

Tim

Andrew Premdas

unread,
Feb 25, 2012, 1:22:00 PM2/25/12
to cu...@googlegroups.com
Tim,

There isn't a way to do it. Its not something Cucumber needs. The article you refer to is from 2008, you should read the Cucumber Book if you want to learn current best practice. This is an old issue which comes up time and again, in fact back in 2008 I probably wanted Cucumber to do this before realising that nested steps are unnecessary (evil!). If you want a  simple of example of how you can refactor your steps so this thing is unnecessary have a look at the features and steps in https://github.com/diabolo/avdi_blog, better yet read the Cucumber Book

The purpose of the long output of cucumber is to document the business functionality being exercised, not how that functionality is implemented. What you asking for is actually equivalent of asking the features to nest the source code that implements a feature in the output of the feature.

Hopefully Matt will chime in and tell you how outdated that post is - I'm sure he doesn't write step definitions like that nowadays.

Anyhow I hope this is helpful,

All best

Andrew

Tim Walker

unread,
Feb 25, 2012, 1:58:05 PM2/25/12
to cu...@googlegroups.com
Hi Andrew, 

Thank you for the dialogue. Please know that I have read and re-read the Cucumber book [on my Kindle (I got the Beta) and have a hard-copy at work as part of a reading group, for real]. I have read and re-read your contributions and value them. I value the whole effort in the extreme (being a long time Fit guy converted to Cucumber). In my humble and very respectful estimation the book, however, feels just a little schizophrenic regarding nested steps. Don't get me wrong, it makes you think about this. In the book, your chapters comes right on the heels of a chapter telling you how to nest steps (unless that has been changed in the latest printing that I have not read yet). For me, anyway, it is a moot point because I help maintain a mature library of well written, powerful, reusable, but evil, nested steps. Personally, I like nesting steps. I feel it increases the power of domain experts that aren't programmers and allows the direct re-use of stable steps. I apply Cucumber In an extremely complex domain and I can say that a very rich domain specific vocabulary is being expressed in this manner. I'm a relish-boy and would like to see support for it there too. Thus, I'd like to see the inner-steps as they run, it would be extremely useful to me as a user of Cucumber. If it ainna possible, so be it. I just want it.  

Thanks again. 

Tim 

Andrew Premdas

unread,
Feb 26, 2012, 9:23:31 AM2/26/12
to cu...@googlegroups.com
On 25 February 2012 18:58, Tim Walker <walk...@gmail.com> wrote:
Hi Andrew, 

Thank you for the dialogue. Please know that I have read and re-read the Cucumber book [on my Kindle (I got the Beta) and have a hard-copy at work as part of a reading group, for real]. I have read and re-read your contributions and value them. I value the whole effort in the extreme (being a long time Fit guy converted to Cucumber). In my humble and very respectful estimation the book, however, feels just a little schizophrenic regarding nested steps. Don't get me wrong, it makes you think about this. In the book, your chapters comes right on the heels of a chapter telling you how to nest steps (unless that has been changed in the latest printing that I have not read yet). For me, anyway, it is a moot point because I help maintain a mature library of well written, powerful, reusable, but evil, nested steps. Personally, I like nesting steps. I feel it increases the power of domain experts that aren't programmers and allows the direct re-use of stable steps. I apply Cucumber In an extremely complex domain and I can say that a very rich domain specific vocabulary is being expressed in this manner. I'm a relish-boy and would like to see support for it there too. Thus, I'd like to see the inner-steps as they run, it would be extremely useful to me as a user of Cucumber. If it ainna possible, so be it. I just want it.  

Thanks again. 

Tim 


Thanks for the context and the kind words Tim. It would be interesting to see you features and understand your context. My theory about nested steps is that no matter how powerful and well written they are, they can always be improved by removing the nesting. This comes down to the fact that any nested step is fundamentally a call to a ruby method with a really ugly method signature. By extracted a method, refactoring the name and then calling this improved method signature you get something that is inherently more expressive and easier to use. Fundamentally ruby code is a much more expressive and powerful and precise tool for programming than gherkin (or any natural language for that matter). 

Your argument about direct re-use is flawed. If you are writing anything in a step definition you are programming. You only have to look at their filename to see this (xxx_steps.rb). Direct re-use is reusing a step in a feature. In practice this only becomes common place if the features are too imperative. Otherwise the fact that each feature has its own context means that each feature tends to have its own language.  In a similar vien the idea that domain experts that aren't programmers can work inside step definitions is flawed. I'll reiterate, if you're writing step definitions you are programming.

As far as the book is concerned, I only have a sidebar in it. I believe both Matt and Aslak are comfortable with nested steps in moderation, so my input is somewhat contrary to the overall flow of the book. As a self proclaimed Cucumber extremist, so I see no place for nested steps, and also question the need for tables and example groups but hey thats just me, hopefully some strong opinions livens the debate and provides a spectrum of practice to utilise.

I'm not the one so say that your request is not possible. I just don't think it would be good for Cucumber, I see a parallel here with web_steps - which also weren't good for cucumber. So even if you implemented the feature yourself and submitted a patch for it I'd vote against it. Buy hey again thats just me, and I count for diddly.

I wanted this very same functionality in the past and now I'm strongly opposed to it. Of course I think I'm older and wiser (rather than just senile) so I'm trying to pass on my perceived knowledge.

Anyhow thanks again for keeping the discussion friendly and pleasant - despite my dogma :)

All best

Andrew

Tim Walker

unread,
Feb 26, 2012, 11:25:55 AM2/26/12
to cu...@googlegroups.com
Hi Andrew, 

You may have hit something on the head when you said: "If you are writing anything in a step definition you are programming. You only have to look at their filename to see this (xxx_steps.rb)". Now there are lots of ways to interpret the word "programming"  which is really just layer on layer of typing abstractions until we reach a high-level language, which could include Gherkin as easily as ruby. This thought further evolves by your definition: you are "programming" when your steps are encapsulated with quotes but "doing something else" when they are not.  While this might seem ironic I get this and tend to agree with you: it's hard enough to get non-developers to read or write in Gherkin, which is really what separates Cucumber from RSpec (IMO),  

In your contributions you have suggested one manner of dealing with this thorny issue. Perhaps others will emerge as this discipline evolves. 

Perhaps there will be support to match steps in .feature files (maybe no regexp at all, exact string matches) before matching them in .rb files. Maybe we can match the Scenario string, or something?. Who knows.

That said, it still does not seem likely that I will get to have a  "-n Show nested steps" option for Cucumber anytime soon. But I still really, really want this capability. 8) 

Happy Cukin', 

Tim 

Chandandeep Singh

unread,
Jul 31, 2013, 1:36:02 AM7/31/13
to cu...@googlegroups.com
Hi Damon,

I am also a newbie in this,. if that works for you , please let me know where to write this command, In code means what, in the feature file or in step def ?

Thanks in advance
Chandandeep Singh

anuja tol

unread,
Aug 20, 2013, 7:17:35 AM8/20/13
to cu...@googlegroups.com
cucumber features --format html --out reports
This will work surely

Deepa S

unread,
May 11, 2015, 9:49:13 AM5/11/15
to cu...@googlegroups.com
I am using cucumber with java, how can I generate the reports.

Harold Meder

unread,
May 31, 2015, 3:32:53 AM5/31/15
to cu...@googlegroups.com
To generate an html report, include the html:<relativeFilePath> option in the CucumberOptions.  
<relativeFilePath> specifies where you would like to report to be generated.

Ajay Sithagari

unread,
Feb 4, 2016, 9:40:21 PM2/4/16
to Cukes
Hi All,
How to generate "DATE AND TIME" inside the report.

Thanks,

Andrew Premdas

unread,
Feb 4, 2016, 10:03:47 PM2/4/16
to cu...@googlegroups.com
Hi Ajay,

I moderate this mailing list. Please don't ressurect old threads and post essentially the same post multiple times. Instead create one new post.

All best

Andrew

--
Posting rules: http://cukes.info/posting-rules.html
---
You received this message because you are subscribed to the Google Groups "Cukes" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cukes+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

srikar....@gmail.com

unread,
Jun 3, 2016, 7:50:03 AM6/3/16
to Cukes, chenzif...@gmail.com
Can anyone let me know am trying to print scenario name also in the report. Please advice.

Andrew Premdas

unread,
Jun 3, 2016, 11:36:03 AM6/3/16
to cu...@googlegroups.com
Hey srikar,

I moderate this mailing list. Please don't ressurect old threads. This one ended in 2012. instead create a new post with your question.

Many thanks

Andrew


--
Posting rules: http://cukes.info/posting-rules.html
---
You received this message because you are subscribed to the Google Groups "Cukes" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cukes+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages