Created
November 7, 2010 13:41
-
-
Save andrewn/666125 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1) Save the text below as /features/support/pie_chart_formatter.rb | |
2) Run cucumber -f PieChartFormatter | |
That spits out a URL with your scenario stats | |
----- | |
class PieChartFormatter | |
def initialize(step_mother, io, options) | |
@io = io | |
@step_mother = step_mother | |
@options = options | |
@status_counts = { :failed => 0, :passed => 0, :pending => 0 } | |
@scenario_status = :pending | |
end | |
def after_step_result(keyword, step_match, multiline_arg, status, | |
exception, source_indent, background) | |
if status == :failed | |
@scenario_status = :failed | |
elsif status == :passed | |
@scenario_status = :passed | |
end | |
end | |
def after_steps(steps) | |
@status_counts[@scenario_status] += 1 | |
@scenario_status = :pending | |
end | |
def after_features(features) | |
data = | |
"#{@status_counts[:passed]},#{@status_counts[:failed]},#{@status_counts[ | |
:pending]}" | |
puts | |
"http://chart.apis.google.com/chart?cht=p3&chd=t:#{data}&chs=250x100&chl | |
=Passed|Failed|Pending" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment