Skip to content

Commit

Permalink
Pretty formatter shows number of scenarios
Browse files Browse the repository at this point in the history
  • Loading branch information
Joseph Wilk committed Dec 23, 2008
1 parent 81dbd58 commit 8838ab1
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
2 changes: 2 additions & 0 deletions History.txt
@@ -1,6 +1,8 @@
== In Git

=== New features
* Pretty formatter shows number of scenarios (#139 Joseph Wilk)

=== Bugfixes
=== Removed features

Expand Down
10 changes: 7 additions & 3 deletions lib/cucumber/formatters/pretty_formatter.rb
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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?
Expand All @@ -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)}
Expand Down
15 changes: 14 additions & 1 deletion spec/cucumber/formatters/pretty_formatter_spec.rb
Expand Up @@ -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={})
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 8838ab1

Please sign in to comment.