Best way to get cucumber test scenarios time execution (through Ruby scripts)

3,250 views
Skip to first unread message

Rodrigo B. Tolledo

unread,
Mar 24, 2013, 2:02:25 PM3/24/13
to cu...@googlegroups.com
Hi folks,

I'm writing some Ruby scripts in order to analyze cucumber scenarios and extract some useful information.
I'd like to compare test time execution, so I'm wondering what's the best way to get (or parse) the time execution of my test scenarios.

The idea is that my Ruby scripts are going to run automatically a bunch of cucumber test scenarios and get the time execution of each of them in order to do some comparison later.

This is what Cucumber prints at the screen (in bold is the information I want to capture with my Ruby scripts):

14 scenarios (14 passed)
42 steps (42 passed)
0m0.032s

Any ideas?

Thanks a lot!

-- Rodrigo

Aslak Hellesøy

unread,
Mar 24, 2013, 3:32:37 PM3/24/13
to cu...@googlegroups.com
The usage formatter already does this. 
--help for details. 

Aslak
Thanks a lot!

-- Rodrigo

--
-- Rules --
 
1) Please prefix the subject with [Ruby], [JVM] or [JS].
2) Please use interleaved answers http://en.wikipedia.org/wiki/Posting_style#Interleaved_style
3) If you have a question, don't reply to an existing message. Start a new topic instead.
 
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 https://groups.google.com/d/forum/cukes?hl=en
---
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/groups/opt_out.
 
 

Rodrigo B. Tolledo

unread,
Mar 24, 2013, 4:47:44 PM3/24/13
to cu...@googlegroups.com
Nice! Just tried that and works fine.

However, it shows the time execution for each step(Given/When/And/Then) of the whole .feature file.

I was wondering if is there any way that I can have the time execution per scenario? Or should I parse this information by myself and sum the time execution values of Given/When/Then to have the total time execution of a scenario?

Cheers!

-- Rodrigo

Rick Beyer

unread,
Apr 29, 2013, 10:34:23 PM4/29/13
to cu...@googlegroups.com
I actually just wrote a gem that pulls out this information for my own tracking.  I have a rails app that tracks the performance of our functional tests.  Right now my gem only works for the JSON format but I am currently adding HTML support.  It doesn't work with Scenario Outlines as of yet as they do not have the desired amount of tracking I initially wanted (Gherkin 3 will).


In your ruby script:
require 'cuke_parser'

result = CukeParser.json(file_path)
file_path is the location to the directory where the cucumber.json file is (it currently expects the file to be named cucumber.json).

If you want to quickly dump the result to see what I pulled out for you

CukeParser.write_build(result,output)

where output is the file you want to dump everything to.

I track the overall duration for the entire suite of tests that were run as well as each individual feature, scenario and step.  I also retrieve the reason for a failure and any screenshots associated with the failed step.  The status of each step, scenario, feature and suite is tracked as well.

I am going to open up the repo to the public soon, just need to finish some coding on it.  If you find it useful please ask for feature requests or report bugs. thanks!

Oscar Rieken

unread,
Apr 29, 2013, 10:49:50 PM4/29/13
to cu...@googlegroups.com
https://github.com/moredip/timestamped-scenarios 

This gem provides custom cucumber formatters which append a test run timestamp to each scenario name as it is generated. aTimestamped::PrettyFormatter and Timestamped::HtmlFormatter are supplied already, but you can use the AddsTimestampmodule to dynamically add timestamping to pretty much any Cucumber formatter.
Reply all
Reply to author
Forward
0 new messages