Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Implement catching and reporting of errors.

  • Loading branch information...
commit 642308200f9bdd071f1697c37de9d4189c596737 1 parent 753757b
@mathie mathie authored
Showing with 38 additions and 0 deletions.
  1. +38 −0 lib/ci/reporter/cucumber.rb
View
38 lib/ci/reporter/cucumber.rb
@@ -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
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.