Skip to content

Commit

Permalink
Less noisy output
Browse files Browse the repository at this point in the history
  • Loading branch information
aslakhellesoy committed Jan 24, 2009
1 parent f86140c commit 5e2cf45
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 41 deletions.
30 changes: 13 additions & 17 deletions features/cucumber_cli.feature
Expand Up @@ -12,7 +12,7 @@ Feature: Cucumber command line
Given missing
1 scenario
1 step undefined
1 undefined step
"""

Expand All @@ -33,8 +33,8 @@ Feature: Cucumber command line
features/sample.feature:12:in `Given failing'
2 scenarios
1 step failed
1 step undefined
1 failed step
1 undefined step
"""

Expand All @@ -49,7 +49,7 @@ Feature: Cucumber command line
Given missing
1 scenario
1 step passed
1 passed step
"""

Expand All @@ -65,7 +65,7 @@ Feature: Cucumber command line
| c | d |
1 scenario
1 step passed
1 passed step
"""

Expand All @@ -75,21 +75,17 @@ Feature: Cucumber command line
"""
U.F
(::) undefined (::)
features/sample.feature:4:in `Given missing'
(::) failed (::)
(::) failed steps (::)
FAIL (RuntimeError)
./features/step_definitions/sample_steps.rb:2:in `flunker'
./features/step_definitions/sample_steps.rb:9:in `/^failing$/'
features/sample.feature:12:in `Given failing'
3 scenarios
1 step failed
1 step undefined
1 step passed
1 failed step
1 undefined step
1 passed step
"""

Expand Down Expand Up @@ -118,7 +114,7 @@ Feature: Cucumber command line
Så skal resultatet være 13
2 scenarios
9 steps passed
9 passed steps
"""

Expand Down Expand Up @@ -171,8 +167,8 @@ Feature: Cucumber command line
Given failing
10 scenarios
9 steps skipped
7 steps undefined
9 skipped steps
7 undefined steps
"""

Expand Down Expand Up @@ -216,6 +212,6 @@ Feature: Cucumber command line
1 scenario
1 step passed
1 passed step
"""
26 changes: 12 additions & 14 deletions features/cucumber_cli_outlines.feature
Expand Up @@ -23,10 +23,10 @@ Feature: Cucumber command line
features/outline_sample.feature:12:in `Given failing without a table'
3 scenarios
1 step failed
2 steps skipped
1 step undefined
2 steps passed
1 failed step
2 skipped steps
1 undefined step
2 passed steps
"""

Expand All @@ -49,8 +49,8 @@ Feature: Cucumber command line
features/outline_sample.feature:12:in `Given failing without a table'
1 scenario
1 step failed
1 step skipped
1 failed step
1 skipped step
"""

Expand All @@ -60,23 +60,21 @@ Feature: Cucumber command line
"""
UUS..FS
(::) undefined (::)
(::) undefined scenarios (::)
features/outline_sample.feature:3:in `Scenario: I have no steps'
features/outline_sample.feature:10:in `Given missing without a table'
(::) failed (::)
(::) failed steps (::)
FAIL (RuntimeError)
./features/step_definitions/sample_steps.rb:2:in `flunker'
./features/step_definitions/sample_steps.rb:16:in `/^failing without a table$/'
features/outline_sample.feature:12:in `Given failing without a table'
4 scenarios
1 step failed
2 steps skipped
1 step undefined
2 steps passed
1 failed step
2 skipped steps
1 undefined step
2 passed steps
"""
2 changes: 1 addition & 1 deletion features/report_called_undefined_steps.feature
Expand Up @@ -19,7 +19,7 @@ Feature: Cucumber command line
./features/step_definitions/sample_steps.rb:20:in `/^a step definition that calls an undefined step$/'
2 scenarios
2 steps undefined
2 undefined steps
You can implement step definitions for missing steps with these snippets:
Expand Down
22 changes: 14 additions & 8 deletions lib/cucumber/formatter/console.rb
Expand Up @@ -30,20 +30,26 @@ def format_string(string, status)
end
end

def print_undefined_scenarios(io, features)
elements = features.scenarios.select{|scenario| scenario.undefined?}
print_elements(io, elements, :undefined, 'scenarios')
end

def print_steps(io, features, status)
steps = status == :undefined ? features.scenarios.select{|scenario| scenario.undefined?} : []
steps += features.steps[status].dup
print_elements(io, features.steps[status], status, 'steps')
end

if steps.any?
io.puts(format_string("(::) #{status} (::)", status))
def print_elements(io, elements, status, kind)
if elements.any?
io.puts(format_string("(::) #{status} #{kind} (::)", status))
io.puts
end

steps.each_with_index do |step, i|
elements.each_with_index do |element, i|
if status == :failed
print_exception(io, step.exception, 0)
print_exception(io, element.exception, 0)
else
io.puts(format_string(step.backtrace_line, status))
io.puts(format_string(element.backtrace_line, status))
end
io.puts
end
Expand Down Expand Up @@ -83,7 +89,7 @@ def print_snippets(io, features, options)
private

def dump_count(count, what, state=nil)
[count, "#{what}#{count == 1 ? '' : 's'}", state].compact.join(" ")
[count, state, "#{what}#{count == 1 ? '' : 's'}"].compact.join(" ")
end

def format_for(*keys)
Expand Down
3 changes: 2 additions & 1 deletion lib/cucumber/formatter/progress.rb
Expand Up @@ -41,10 +41,11 @@ def visit_table_cell_value(value, width, status)
private

def print_summary(io, features)
print_steps(io, features, :undefined)
print_undefined_scenarios(io, features)
print_steps(io, features, :pending)
print_steps(io, features, :failed)
print_counts(io, features)
print_snippets(io, features, @options)
end

CHARS = {
Expand Down

0 comments on commit 5e2cf45

Please sign in to comment.