Class: CI::Reporter::Cucumber

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(step_mother, io, options) ⇒ Cucumber

Returns a new instance of Cucumber.



45
46
47
# File 'lib/ci/reporter/cucumber.rb', line 45

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

Instance Attribute Details

#nameObject

Returns the value of attribute name.



43
44
45
# File 'lib/ci/reporter/cucumber.rb', line 43

def name
  @name
end

#report_managerObject

Returns the value of attribute report_manager.



43
44
45
# File 'lib/ci/reporter/cucumber.rb', line 43

def report_manager
  @report_manager
end

#test_suiteObject

Returns the value of attribute test_suite.



43
44
45
# File 'lib/ci/reporter/cucumber.rb', line 43

def test_suite
  @test_suite
end

Instance Method Details

#after_background(*args) ⇒ Object



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

def after_background(*args)
end

#after_examples(*args) ⇒ Object



100
101
# File 'lib/ci/reporter/cucumber.rb', line 100

def after_examples(*args)
end

#after_feature(feature) ⇒ Object



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

def after_feature(feature)
  test_suite.name = @name
  test_suite.finish
  report_manager.write_report(@test_suite)
  @test_suite = nil
end

#after_steps(steps) ⇒ Object



80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/ci/reporter/cucumber.rb', line 80

def after_steps(steps)
  @test_case.finish

  case steps.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(steps)
  end

  test_suite.testcases << @test_case
  @test_case = nil
end

#after_table_row(table_row) ⇒ Object



113
114
115
116
117
118
119
120
121
122
123
124
# File 'lib/ci/reporter/cucumber.rb', line 113

def after_table_row(table_row)
  if @header_row
    @header_row = false
    return
  end
  @test_case.finish
  if table_row.respond_to? :failed?
    @test_case.failures << CucumberFailure.new(table_row) if table_row.failed?
    test_suite.testcases << @test_case
    @test_case = nil
  end
end

#before_background(*args) ⇒ Object



61
62
# File 'lib/ci/reporter/cucumber.rb', line 61

def before_background(*args)
end

#before_examples(*args) ⇒ Object



96
97
98
# File 'lib/ci/reporter/cucumber.rb', line 96

def before_examples(*args)
  @header_row = true
end

#before_feature(feature) ⇒ Object



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

def before_feature(feature)
  self.test_suite = TestSuite.new(@name)
  test_suite.start
end

#before_steps(steps) ⇒ Object



75
76
77
78
# File 'lib/ci/reporter/cucumber.rb', line 75

def before_steps(steps)
  @test_case = TestCase.new(@scenario)
  @test_case.start
end

#before_table_row(table_row) ⇒ Object



103
104
105
106
107
108
109
110
111
# File 'lib/ci/reporter/cucumber.rb', line 103

def before_table_row(table_row)
  row = table_row # shorthand for table_row
  # check multiple versions of the row and try to find the best fit
  outline = (row.respond_to? :name)             ? row.name :
            (row.respond_to? :scenario_outline) ? row.scenario_outline :
                                                  row.to_s
  @test_case = TestCase.new("#@scenario (outline: #{outline})")
  @test_case.start
end

#feature_name(keyword, name) ⇒ Object



67
68
69
# File 'lib/ci/reporter/cucumber.rb', line 67

def feature_name(keyword, name)
  @name = (name || "Unnamed feature").split("\n").first
end

#scenario_name(keyword, name, *args) ⇒ Object



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

def scenario_name(keyword, name, *args)
  @scenario = (name || "Unnamed scenario").split("\n").first
end