timestamped-scenarios, a custom Cucumber formatter
November 20, 2010
What's this gem for?
This gem provides custom cucumber formatters which append a test run timestamp to each scenario name as it is generated. a Timestamped::PrettyFormatter and Timestamped::HtmlFormatter are supplied already, but you can use the AddsTimestamp module to dynamically add timestamping to pretty much any Cucumber formatter.
You might wonder why I created these formatters. I'm currently working on an iOS project where we are using Frank and Cucumber to run automated acceptance tests against the application. We have integrated these acceptance tests into our CI build, and as part of that integration we record a screen capture movie of each test run. By adding timestamps to each scenario name we can easily skip to the part of the movie which shows that scenario executing. This is useful when trying to figure out the context around why a
specific scenario failed.
How do you use it?
As with my other cucumber formatter gem (slowhandcuke), getting set up with timestamped-scenarios is super easy. just install the gem with
gem install timestamped-scenarios
and you're ready to use them by executing cucumber with something like cucumber --format 'Timestamped::HtmlFormatter' --out cucumber.html
You can also add these parameters to your rake cucumber task, or to your cucumber.yml config file. There's also a little sample project in the timestamped-scenarios repo on github which shows how to use the formatters.What's it look like?
Here's an example of what the Timestamped::PrettyFormatter output looks like:
∴ cucumber
Using the default profile...
Feature: demonstration
Scenario: The First [0:00] # the.feature:3
Given I wait 5 seconds # step_definitions/steps.rb:1
Scenario: The Second [0:05] # the.feature:6
Given I wait 0.7 seconds # step_definitions/steps.rb:1
Given I wait 3 seconds # step_definitions/steps.rb:1
Scenario: The Third [0:09] # the.feature:10
3 scenarios (3 passed)
3 steps (3 passed)
0m8.709s