diff --git a/History.txt b/History.txt index ae16bf719e..e71059a416 100644 --- a/History.txt +++ b/History.txt @@ -1,6 +1,8 @@ == In Git === New features +* Pretty formatter shows number of scenarios (#139 Joseph Wilk) + === Bugfixes === Removed features diff --git a/lib/cucumber/formatters/pretty_formatter.rb b/lib/cucumber/formatters/pretty_formatter.rb index 44ede39dae..382c02260e 100644 --- a/lib/cucumber/formatters/pretty_formatter.rb +++ b/lib/cucumber/formatters/pretty_formatter.rb @@ -19,6 +19,8 @@ def initialize(io, step_mother, options={}) @last_executed_was_row = false @pending_messages = {} @forced_pending_step_count = 0 + + @total_scenario_count = 0 end def feature_executing(feature) @@ -81,6 +83,7 @@ def scenario_executed(scenario) @io.puts output_failing_step(@failed.last) end + @total_scenario_count += 1 end def step_passed(step, regexp, args) @@ -100,14 +103,13 @@ def step_passed(step, regexp, args) end def step_failed(step, regexp, args) + @scenario_failed = true if step.row? args = step.visible_args if step.outline? @failed << step - @scenario_failed = true print_failed_args(args) else @failed << step - @scenario_failed = true @io.print failed(" #{step.keyword} #{step.format(regexp){|param| failed_param(param) << failed}}") if @options[:source] @io.print padding_spaces(step) @@ -176,6 +178,8 @@ def dump print_pending_messages if @pending_messages.any? + @io.puts "#{@total_scenario_count} scenarios" + @io.puts pending("#{@pending_scenarios.length} scenarios pending") if @pending_scenarios.any? @io.puts passed("#{@passed.length} steps passed") if @passed.any? @@ -199,7 +203,7 @@ def print_pending_messages end @io.puts end - + def print_snippets snippets = @pending_steps snippets.delete_if {|snippet| snippet.row? || @step_mother.has_step_definition?(snippet.name)} diff --git a/spec/cucumber/formatters/pretty_formatter_spec.rb b/spec/cucumber/formatters/pretty_formatter_spec.rb index 1eeb80c2aa..d3bd096d08 100644 --- a/spec/cucumber/formatters/pretty_formatter_spec.rb +++ b/spec/cucumber/formatters/pretty_formatter_spec.rb @@ -31,7 +31,8 @@ def mock_scenario(stubs={}) :file => 'file', :line => 1, :padding_length => 2, - :outline? => false}.merge(stubs)) + :outline? => false, + :table_header => nil}.merge(stubs)) end def mock_scenario_outline(stubs={}) @@ -314,6 +315,18 @@ def mock_proc(stubs={}) io.string.should include("1 with no step definition") end + it "should display the total number of scenarios executed" do + io = StringIO.new + formatter = PrettyFormatter.new io, mock('step_mother') + + formatter.scenario_executing(mock_scenario) + formatter.scenario_executed(mock_scenario) + + formatter.dump + + io.string.should include("1 scenarios") + end + describe "colour" do before(:all) do