This repository has been archived by the owner on Jan 9, 2019. It is now read-only.
forked from ci-reporter/ci_reporter
/
cucumber.rb
81 lines (71 loc) · 2.02 KB
/
cucumber.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# (c) Copyright 2006-2009 Nick Sieger <nicksieger@gmail.com>
# See the file LICENSE.txt included with the distribution for
# software license details.
require 'ci/reporter/core'
tried_gem = false
begin
require 'cucumber'
require 'cucumber/formatter/progress'
require 'cucumber/formatter/pretty'
rescue LoadError
unless tried_gem
tried_gem = true
require 'rubygems'
gem 'cucumber'
retry
end
end
module CI
module Reporter
class Cucumber < ::Cucumber::Formatter::Progress
def initialize(*args, &block)
super
@report_manager = ReportManager.new("cucumber")
@current_suite = nil
@current_test = nil
end
def visit_feature_name(name)
@feature_name = name.split("\n").first
super
end
def visit_scenario_name(keyword, name, file_colon_line, source_indent)
start_scenario("#{@feature_name}-#{name}")
super
end
def visit_step_name(keyword, step_match, status, source_indent, background)
start_scenario(step_match) unless status == :outline
super
end
private
def start_scenario(suite_name)
finish_scenario unless @current_suite.nil?
@current_suite = TestSuite.new(suite_name)
@current_suite.start
end
def finish_scenario
finish_example unless @current_test.nil?
unless @current_suite.nil?
@current_suite.finish
# puts @current_suite.inspect
@report_manager.write_report(@current_suite)
@current_suite = nil
end
end
def start_example(test_name)
finish_example unless @current_test.nil?
@current_test = TestCase.new(test_name)
@current_test.start
puts @current_test.inspect
end
def finish_example
unless @current_test.nil?
@current_test.finish
@current_suite.testcases << @current_test
@current_test = nil
end
end
end
class CucumberDoc < ::Cucumber::Formatter::Pretty
end
end
end