Class: CI::Reporter::Cucumber

Inherits:
Object
  • Object
show all
Defined in:
lib/ci/reporter/cucumber.rb

Instance Method Summary collapse

Constructor Details

#initialize(step_mother, io, options) ⇒ Cucumber

Returns a new instance of Cucumber.



50
51
52
# File 'lib/ci/reporter/cucumber.rb', line 50

def initialize(step_mother, io, options)
  @report_manager = ReportManager.new("features")
end

Instance Method Details

#after_feature_element(feature_element) ⇒ Object



63
64
65
66
67
# File 'lib/ci/reporter/cucumber.rb', line 63

def after_feature_element(feature_element)
  @test_suite.finish
  @report_manager.write_report(@test_suite)
  @test_suite = nil
end

#after_step(step) ⇒ Object



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/ci/reporter/cucumber.rb', line 74

def after_step(step)
  if @test_case.nil? 
    $stderr << "Warning, no test case was started for #{step}. Time won't be logged."
    @test_case = TestCase.new(step.name)
    @test_case.start
  end
  @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

  if @test_suite.nil? 
    $stderr << "Warning, no test suite was started for the scenario around #{step}. Time logging will be wrong."
    @test_suite = TestSuite.new("#{@current_feature_name} Unspecified Feature Element")
    @test_suite.start
  end
  @test_case.finish
  @test_suite.testcases << @test_case
end

#before_feature_element(feature_element) ⇒ Object



58
59
60
61
# File 'lib/ci/reporter/cucumber.rb', line 58

def before_feature_element(feature_element)
  @test_suite = TestSuite.new("#{@current_feature_name} #{feature_element.instance_variable_get("@name")}")
  @test_suite.start
end

#before_feature_name(name) ⇒ Object



54
55
56
# File 'lib/ci/reporter/cucumber.rb', line 54

def before_feature_name(name)
  @current_feature_name = name.split("\n").first
end

#before_step(step) ⇒ Object



69
70
71
72
# File 'lib/ci/reporter/cucumber.rb', line 69

def before_step(step)
  @test_case = TestCase.new(step.name)
  @test_case.start
end