Skip to content

Commit

Permalink
Implement catching and reporting of errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
mathie committed May 4, 2009
1 parent 753757b commit 6423082
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions lib/ci/reporter/cucumber.rb
Expand Up @@ -19,6 +19,34 @@

module CI
module Reporter
class CucumberFailure
attr_reader :step

def initialize(step)
@step = step
end

def failure?
step.exception.is_a? StandardError
end

def error?
!failure?
end

def name
step.exception.class.name
end

def message
step.exception.message
end

def location
step.exception.backtrace.join("\n")
end
end

class Cucumber < ::Cucumber::Formatter::Progress

attr_accessor :test_suite, :report_manager, :feature_name
Expand Down Expand Up @@ -53,6 +81,16 @@ def visit_step(step)
return_value = super

test_case.finish

case step.status
when :pending, :undefined
test_case.name = "#{test_case.name} (PENDING)"
when :skipped
test_case.name = "#{test_case.name} (SKIPPED)"
when :failed
test_case.failures << CucumberFailure.new(step)
end

test_suite.testcases << test_case

return_value
Expand Down

0 comments on commit 6423082

Please sign in to comment.