qat-reporter 6.1.6 → 6.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/qat/formatter/json.rb +3 -7
- data/lib/qat/formatter/req_coverage.rb +3 -123
- data/lib/qat/formatter/time_measurements.rb +3 -186
- data/lib/qat/reporter/formatter/json.rb +18 -0
- data/lib/qat/reporter/formatter/req_coverage.rb +136 -0
- data/lib/qat/reporter/formatter/time_measurements.rb +191 -0
- data/lib/qat/reporter/formatters/ascii_table.rb +4 -44
- data/lib/qat/reporter/helpers/ascii_table.rb +54 -0
- data/lib/qat/reporter/helpers/time_format.rb +16 -0
- data/lib/qat/reporter/helpers.rb +2 -0
- data/lib/qat/reporter/hooks/time_reporter.rb +2 -1
- data/lib/qat/reporter/times/helpers.rb +4 -8
- data/lib/qat/reporter/times/report.rb +3 -4
- data/lib/qat/reporter/times.rb +2 -3
- data/lib/qat/reporter/version.rb +1 -1
- data/lib/qat/reporter.rb +3 -0
- metadata +8 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5618ba12c5dfad947f4fd4fd08a179c8ff75188ea9a2ae9662b130fa2cb3627c
|
4
|
+
data.tar.gz: fe0097a87bb54df10095a5642078b01cf71319dee8199bb620f86db1c0f45f6f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b76aca4f0beadacf9795bfff9b956958d8fa79896edb5d9ec826c5806d8a69f430d5c1636280cba82d4367916c446f3e4b14dd6d56895dabb11fd6d2a5ea5f26
|
7
|
+
data.tar.gz: 44ff68d21f4e293386742ed3fd77fcf8603b1760e4f9a36c57eb2c395ba900bcdcb7f41ded4b4263a81ac0fcc524c9ebc62fb58549efc2cece47ceabf8fcb8e1
|
data/lib/qat/formatter/json.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
|
1
|
+
warn "[WARN] DEPRECATED: QAT::Formatter::Json will be removed in a 7.0 version, please use QAT::Reporter::Formatter::Json"
|
2
|
+
require_relative '../reporter/formatter/json'
|
2
3
|
|
3
4
|
module QAT
|
4
5
|
# Namespace for custom Cucumber formatters and helpers.
|
@@ -6,11 +7,6 @@ module QAT
|
|
6
7
|
module Formatter
|
7
8
|
# Namespace for Json formatter
|
8
9
|
#@since 6.1.0
|
9
|
-
|
10
|
-
|
11
|
-
#@api private
|
12
|
-
def embed *_
|
13
|
-
end
|
14
|
-
end
|
10
|
+
Json = QAT::Reporter::Formatter::Json
|
15
11
|
end
|
16
12
|
end
|
@@ -1,11 +1,5 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require 'cucumber/formatter/duration'
|
4
|
-
require 'cucumber/formatter/duration_extractor'
|
5
|
-
require 'json'
|
6
|
-
require 'fileutils'
|
7
|
-
require 'qat/logger'
|
8
|
-
require 'qat/formatter/loggable'
|
1
|
+
warn "[WARN] DEPRECATED: QAT::Formatter::ReqCoverage will be removed in a 7.0 version, please use QAT::Reporter::Formatter::ReqCoverage"
|
2
|
+
require_relative '../reporter/formatter/req_coverage'
|
9
3
|
|
10
4
|
module QAT
|
11
5
|
# Namespace for custom Cucumber formatters and helpers.
|
@@ -13,120 +7,6 @@ module QAT
|
|
13
7
|
module Formatter
|
14
8
|
# Namespace for ReqCoverage formatter
|
15
9
|
#@since 1.0.0
|
16
|
-
|
17
|
-
include ::Cucumber::Formatter::Io
|
18
|
-
include ::Cucumber::Formatter::Duration
|
19
|
-
include QAT::Formatter::Loggable
|
20
|
-
include QAT::Logger
|
21
|
-
|
22
|
-
#@api private
|
23
|
-
def initialize(runtime, path_or_io, options)
|
24
|
-
@io = ensure_io(path_or_io)
|
25
|
-
@options = options
|
26
|
-
@test_results = []
|
27
|
-
|
28
|
-
ensure_outputter 'ReqCoverage' unless options[:dry_run]
|
29
|
-
end
|
30
|
-
|
31
|
-
#@api private
|
32
|
-
def before_feature(*_)
|
33
|
-
@feature_requirement_ids = []
|
34
|
-
@test_requirement_ids = []
|
35
|
-
@in_test_cases = false
|
36
|
-
@row_counter = 0
|
37
|
-
@flag_tag = nil
|
38
|
-
end
|
39
|
-
|
40
|
-
#@api private
|
41
|
-
def feature_name(*_)
|
42
|
-
@in_test_cases = true
|
43
|
-
end
|
44
|
-
|
45
|
-
#@api private
|
46
|
-
def tag_name(tag_name)
|
47
|
-
@test_id = tag_name.to_s.split('#')[1] if tag_name.match(/@test#(\d+)/)
|
48
|
-
requirement_id = tag_name.to_s.split('#')[1] if tag_name.match(/@user_story#(\d+)/)
|
49
|
-
if @in_test_cases
|
50
|
-
@test_requirement_ids << requirement_id
|
51
|
-
else
|
52
|
-
@feature_requirement_ids << requirement_id
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
#@api private
|
57
|
-
def before_test_case(test_case)
|
58
|
-
@current_scenario = test_case.source[1]
|
59
|
-
unless @current_scenario.is_a?(::Cucumber::Core::Ast::ScenarioOutline)
|
60
|
-
@test_id = nil
|
61
|
-
@test_requirement_ids = []
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
#@api private
|
66
|
-
def after_test_case(_, status)
|
67
|
-
test_status = if status.is_a? ::Cucumber::Core::Test::Result::Passed
|
68
|
-
"passed"
|
69
|
-
elsif status.is_a? ::Cucumber::Core::Test::Result::Failed
|
70
|
-
"failed"
|
71
|
-
else
|
72
|
-
"not_runned"
|
73
|
-
end
|
74
|
-
|
75
|
-
if @current_scenario.is_a? ::Cucumber::Core::Ast::ScenarioOutline
|
76
|
-
if @flag_tag == @test_id
|
77
|
-
@row_counter += 1
|
78
|
-
else
|
79
|
-
@row_counter = 1
|
80
|
-
end
|
81
|
-
|
82
|
-
test_id = "#{@test_id}.#{@row_counter}".to_f
|
83
|
-
else
|
84
|
-
@row_counter = 1
|
85
|
-
test_id = @test_id.to_i
|
86
|
-
end
|
87
|
-
|
88
|
-
duration = ::Cucumber::Formatter::DurationExtractor.new(status).result_duration
|
89
|
-
human_duration = format_duration(duration)
|
90
|
-
|
91
|
-
test_result = {
|
92
|
-
test: test_id,
|
93
|
-
requirement: (@feature_requirement_ids + @test_requirement_ids).uniq.compact,
|
94
|
-
status: test_status,
|
95
|
-
duration: duration,
|
96
|
-
human_duration: human_duration
|
97
|
-
}
|
98
|
-
|
99
|
-
if test_result[:test]
|
100
|
-
@test_results << test_result
|
101
|
-
|
102
|
-
log.info({
|
103
|
-
'message' => 'test execution',
|
104
|
-
'_test' => test_result[:test],
|
105
|
-
'_requirement' => test_result[:requirement],
|
106
|
-
'_status' => test_result[:status],
|
107
|
-
'_duration' => duration,
|
108
|
-
'_human_duration' => human_duration
|
109
|
-
})
|
110
|
-
end
|
111
|
-
|
112
|
-
@test_requirement_ids = [] unless @current_scenario.is_a?(::Cucumber::Core::Ast::ScenarioOutline)
|
113
|
-
@flag_tag = @test_id if @flag_tag != @test_id
|
114
|
-
end
|
115
|
-
|
116
|
-
#@api private
|
117
|
-
def after_features(*_)
|
118
|
-
publish_result
|
119
|
-
end
|
120
|
-
|
121
|
-
|
122
|
-
private
|
123
|
-
# Writes results to a JSON file
|
124
|
-
def publish_result
|
125
|
-
content = {
|
126
|
-
results: @test_results
|
127
|
-
}
|
128
|
-
@io.puts(JSON.pretty_generate(content))
|
129
|
-
end
|
130
|
-
end
|
10
|
+
ReqCoverage = QAT::Reporter::Formatter::ReqCoverage
|
131
11
|
end
|
132
12
|
end
|
@@ -1,193 +1,10 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require 'cucumber/formatter/duration'
|
4
|
-
require 'cucumber/formatter/duration_extractor'
|
5
|
-
require 'json'
|
6
|
-
require 'qat/logger'
|
7
|
-
require 'qat/formatter/loggable'
|
8
|
-
require_relative '../../qat/reporter/times'
|
1
|
+
warn "[WARN] DEPRECATED: QAT::Formatter::TimeMeasurements will be removed in a 7.0 version, please use QAT::Reporter::Formatter::TimeMeasurements"
|
2
|
+
require_relative '../reporter/formatter/time_measurements'
|
9
3
|
|
10
4
|
module QAT
|
11
5
|
# Namespace for custom Cucumber formatters and helpers.
|
12
6
|
#@since 0.1.0
|
13
7
|
module Formatter
|
14
|
-
|
15
|
-
#@since 6.2.0
|
16
|
-
class TimeMeasurements
|
17
|
-
include ::Cucumber::Formatter::Io
|
18
|
-
include ::Cucumber::Formatter::Duration
|
19
|
-
|
20
|
-
def initialize(runtime, path_or_io, options)
|
21
|
-
@io = ensure_io(path_or_io)
|
22
|
-
@options = options
|
23
|
-
@json_content = []
|
24
|
-
end
|
25
|
-
|
26
|
-
#@api private
|
27
|
-
def before_feature(feature)
|
28
|
-
@in_test_cases = false
|
29
|
-
@current_feature = feature
|
30
|
-
@current_feature_timestamp = Time.now.strftime("%FT%T%z")
|
31
|
-
@outline_tags = []
|
32
|
-
@current_feature_info = {
|
33
|
-
feature: @current_feature,
|
34
|
-
tags: [],
|
35
|
-
timestamp: @current_feature_timestamp,
|
36
|
-
scenarios: []
|
37
|
-
}
|
38
|
-
|
39
|
-
@outline_scenario_info = {
|
40
|
-
name: [],
|
41
|
-
tags: [],
|
42
|
-
timestamp: [],
|
43
|
-
test_runs: []
|
44
|
-
}
|
45
|
-
end
|
46
|
-
|
47
|
-
#@api private
|
48
|
-
def feature_name(*_)
|
49
|
-
@in_test_cases = true
|
50
|
-
end
|
51
|
-
|
52
|
-
#@api private
|
53
|
-
def tag_name(tag_name)
|
54
|
-
@test_id = tag_name.to_s
|
55
|
-
@current_feature_info[:tags] << tag_name unless @in_test_cases
|
56
|
-
|
57
|
-
if @in_test_cases
|
58
|
-
if @current_scenario.is_a?(::Cucumber::Core::Ast::ScenarioOutline)
|
59
|
-
@outline_tags << tag_name
|
60
|
-
else
|
61
|
-
@current_scenario_info[:tags] << tag_name
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
#@api private
|
67
|
-
def before_test_case(test_case)
|
68
|
-
@current_scenario = test_case.source[1]
|
69
|
-
@current_scenario_timestamp = Time.now.strftime("%FT%T%z")
|
70
|
-
|
71
|
-
unless @current_scenario.is_a?(::Cucumber::Core::Ast::ScenarioOutline)
|
72
|
-
@current_scenario_info = {
|
73
|
-
name: @current_scenario,
|
74
|
-
tags: [],
|
75
|
-
timestamp: @current_scenario_timestamp,
|
76
|
-
test_runs: []
|
77
|
-
}
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
#@api private
|
82
|
-
def before_outline_table(*_)
|
83
|
-
@outline = true
|
84
|
-
@outline_scenario_info = {
|
85
|
-
name: @current_scenario,
|
86
|
-
tags: [],
|
87
|
-
timestamp: @current_scenario_timestamp,
|
88
|
-
test_runs: []
|
89
|
-
}
|
90
|
-
end
|
91
|
-
|
92
|
-
#@api private
|
93
|
-
def after_test_case(_, status)
|
94
|
-
test_run_id = QAT[:current_test_run_id]
|
95
|
-
measurements = QAT::Reporter::Times.get_measures rescue []
|
96
|
-
|
97
|
-
test_run_info = {
|
98
|
-
id: test_run_id,
|
99
|
-
timestamp: QAT[:test_start_timestamp]&.strftime("%FT%T%z"),
|
100
|
-
measurements: []
|
101
|
-
}
|
102
|
-
|
103
|
-
measurements.each do |id, measure|
|
104
|
-
if id
|
105
|
-
minutes, seconds = measure[:duration].divmod(60)
|
106
|
-
test_run_info[:measurements] << {
|
107
|
-
id: id,
|
108
|
-
name: measure[:name],
|
109
|
-
timestamp: measure[:start].strftime("%FT%T%z"),
|
110
|
-
time: {
|
111
|
-
secs: measure[:duration],
|
112
|
-
human: "#{minutes}m #{'%02.0f' % seconds}s"
|
113
|
-
}
|
114
|
-
}
|
115
|
-
end
|
116
|
-
end
|
117
|
-
|
118
|
-
if @current_scenario.is_a?(::Cucumber::Core::Ast::ScenarioOutline)
|
119
|
-
@outline_scenario_info[:test_runs] << test_run_info
|
120
|
-
else
|
121
|
-
@current_scenario_info[:test_runs] << test_run_info
|
122
|
-
end
|
123
|
-
end
|
124
|
-
|
125
|
-
#@api private
|
126
|
-
def after_examples_array(*_)
|
127
|
-
@outline_scenario_info[:tags] = @outline_tags
|
128
|
-
@current_feature_info[:scenarios] << @outline_scenario_info
|
129
|
-
@outline = true
|
130
|
-
@outline_tags = []
|
131
|
-
end
|
132
|
-
|
133
|
-
#@api private
|
134
|
-
def after_feature_element(*_)
|
135
|
-
#After outline run, here cucumber changes for non outline, flag needed for outlines scenarios
|
136
|
-
if @outline == true
|
137
|
-
@outline = false
|
138
|
-
else
|
139
|
-
@current_feature_info[:scenarios] << @current_scenario_info
|
140
|
-
end
|
141
|
-
@in_test_cases = true
|
142
|
-
end
|
143
|
-
|
144
|
-
#@api private
|
145
|
-
def after_feature(*_)
|
146
|
-
@indexes = []
|
147
|
-
@indexes_test_runs = []
|
148
|
-
@scenarios = @current_feature_info[:scenarios]
|
149
|
-
|
150
|
-
@scenarios.each_with_index do |key, value|
|
151
|
-
test_run = key[:test_runs]
|
152
|
-
#Verifies if exist measures in a test_run
|
153
|
-
test_run.each_with_index do |key, value|
|
154
|
-
if key[:measurements].empty?
|
155
|
-
@indexes << value
|
156
|
-
end
|
157
|
-
end
|
158
|
-
#Deletes the empty measures
|
159
|
-
@indexes.reverse!.each do |v|
|
160
|
-
test_run.delete_at(v)
|
161
|
-
end
|
162
|
-
#Verifies if exist test_runs in a scenarios
|
163
|
-
if key[:test_runs].empty?
|
164
|
-
@indexes_test_runs << value
|
165
|
-
end
|
166
|
-
end
|
167
|
-
#Delete empty test runs:
|
168
|
-
@indexes_test_runs.reverse!.each do |v|
|
169
|
-
@current_feature_info[:scenarios].delete_at(v)
|
170
|
-
end
|
171
|
-
|
172
|
-
@json_content << @current_feature_info unless @scenarios.empty?
|
173
|
-
end
|
174
|
-
|
175
|
-
#@api private
|
176
|
-
def after_features(*_)
|
177
|
-
publish_result
|
178
|
-
end
|
179
|
-
|
180
|
-
private
|
181
|
-
|
182
|
-
def format_duration(seconds)
|
183
|
-
m, s = seconds.divmod(60)
|
184
|
-
"#{m}m #{'%.f' % s}s"
|
185
|
-
end
|
186
|
-
|
187
|
-
# Writes results to a JSON file
|
188
|
-
def publish_result
|
189
|
-
@io.puts(JSON.pretty_generate(@json_content))
|
190
|
-
end
|
191
|
-
end
|
8
|
+
TimeMeasurements = QAT::Reporter::Formatter::TimeMeasurements
|
192
9
|
end
|
193
10
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'cucumber/formatter/json'
|
2
|
+
|
3
|
+
module QAT
|
4
|
+
# Namespace for QAT Reporter
|
5
|
+
module Reporter
|
6
|
+
# Namespace for custom Cucumber formatters and helpers.
|
7
|
+
#@since 6.1.7
|
8
|
+
module Formatter
|
9
|
+
# Namespace for Json formatter
|
10
|
+
#@since 6.1.7
|
11
|
+
class Json < ::Cucumber::Formatter::Json
|
12
|
+
#@api private
|
13
|
+
def embed *_
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,136 @@
|
|
1
|
+
require 'cucumber/formatter/console'
|
2
|
+
require 'cucumber/formatter/io'
|
3
|
+
require 'cucumber/formatter/duration'
|
4
|
+
require 'cucumber/formatter/duration_extractor'
|
5
|
+
require 'json'
|
6
|
+
require 'fileutils'
|
7
|
+
require 'qat/logger'
|
8
|
+
require 'qat/formatter/loggable'
|
9
|
+
|
10
|
+
module QAT
|
11
|
+
# Namespace for QAT Reporter
|
12
|
+
module Reporter
|
13
|
+
# Namespace for custom Cucumber formatters and helpers.
|
14
|
+
#@since 6.1.7
|
15
|
+
module Formatter
|
16
|
+
# Namespace for ReqCoverage formatter
|
17
|
+
#@since 6.1.7
|
18
|
+
class ReqCoverage
|
19
|
+
include ::Cucumber::Formatter::Io
|
20
|
+
include ::Cucumber::Formatter::Duration
|
21
|
+
include QAT::Formatter::Loggable
|
22
|
+
include QAT::Logger
|
23
|
+
|
24
|
+
#@api private
|
25
|
+
def initialize(runtime, path_or_io, options)
|
26
|
+
@io = ensure_io(path_or_io)
|
27
|
+
@options = options
|
28
|
+
@test_results = []
|
29
|
+
|
30
|
+
ensure_outputter 'ReqCoverage' unless options[:dry_run]
|
31
|
+
end
|
32
|
+
|
33
|
+
#@api private
|
34
|
+
def before_feature(*_)
|
35
|
+
@feature_requirement_ids = []
|
36
|
+
@test_requirement_ids = []
|
37
|
+
@in_test_cases = false
|
38
|
+
@row_counter = 0
|
39
|
+
@flag_tag = nil
|
40
|
+
end
|
41
|
+
|
42
|
+
#@api private
|
43
|
+
def feature_name(*_)
|
44
|
+
@in_test_cases = true
|
45
|
+
end
|
46
|
+
|
47
|
+
#@api private
|
48
|
+
def tag_name(tag_name)
|
49
|
+
@test_id = tag_name.to_s.split('#')[1] if tag_name.match(/@test#(\d+)/)
|
50
|
+
requirement_id = tag_name.to_s.split('#')[1] if tag_name.match(/@user_story#(\d+)/)
|
51
|
+
if @in_test_cases
|
52
|
+
@test_requirement_ids << requirement_id
|
53
|
+
else
|
54
|
+
@feature_requirement_ids << requirement_id
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
#@api private
|
59
|
+
def before_test_case(test_case)
|
60
|
+
@current_scenario = test_case.source[1]
|
61
|
+
unless @current_scenario.is_a?(::Cucumber::Core::Ast::ScenarioOutline)
|
62
|
+
@test_id = nil
|
63
|
+
@test_requirement_ids = []
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
#@api private
|
68
|
+
def after_test_case(_, status)
|
69
|
+
test_status = if status.is_a? ::Cucumber::Core::Test::Result::Passed
|
70
|
+
"passed"
|
71
|
+
elsif status.is_a? ::Cucumber::Core::Test::Result::Failed
|
72
|
+
"failed"
|
73
|
+
else
|
74
|
+
"not_runned"
|
75
|
+
end
|
76
|
+
|
77
|
+
if @current_scenario.is_a? ::Cucumber::Core::Ast::ScenarioOutline
|
78
|
+
if @flag_tag == @test_id
|
79
|
+
@row_counter += 1
|
80
|
+
else
|
81
|
+
@row_counter = 1
|
82
|
+
end
|
83
|
+
|
84
|
+
test_id = "#{@test_id}.#{@row_counter}".to_f
|
85
|
+
else
|
86
|
+
@row_counter = 1
|
87
|
+
test_id = @test_id.to_i
|
88
|
+
end
|
89
|
+
|
90
|
+
duration = ::Cucumber::Formatter::DurationExtractor.new(status).result_duration
|
91
|
+
human_duration = format_duration(duration)
|
92
|
+
|
93
|
+
test_result = {
|
94
|
+
test: test_id,
|
95
|
+
requirement: (@feature_requirement_ids + @test_requirement_ids).uniq.compact,
|
96
|
+
status: test_status,
|
97
|
+
duration: duration,
|
98
|
+
human_duration: human_duration
|
99
|
+
}
|
100
|
+
|
101
|
+
if test_result[:test]
|
102
|
+
@test_results << test_result
|
103
|
+
|
104
|
+
log.info({
|
105
|
+
'message' => 'test execution',
|
106
|
+
'_test' => test_result[:test],
|
107
|
+
'_requirement' => test_result[:requirement],
|
108
|
+
'_status' => test_result[:status],
|
109
|
+
'_duration' => duration,
|
110
|
+
'_human_duration' => human_duration
|
111
|
+
})
|
112
|
+
end
|
113
|
+
|
114
|
+
@test_requirement_ids = [] unless @current_scenario.is_a?(::Cucumber::Core::Ast::ScenarioOutline)
|
115
|
+
@flag_tag = @test_id if @flag_tag != @test_id
|
116
|
+
end
|
117
|
+
|
118
|
+
#@api private
|
119
|
+
def after_features(*_)
|
120
|
+
publish_result
|
121
|
+
end
|
122
|
+
|
123
|
+
|
124
|
+
private
|
125
|
+
|
126
|
+
# Writes results to a JSON file
|
127
|
+
def publish_result
|
128
|
+
content = {
|
129
|
+
results: @test_results
|
130
|
+
}
|
131
|
+
@io.puts(JSON.pretty_generate(content))
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
@@ -0,0 +1,191 @@
|
|
1
|
+
require 'cucumber/formatter/console'
|
2
|
+
require 'cucumber/formatter/io'
|
3
|
+
require 'cucumber/formatter/duration'
|
4
|
+
require 'cucumber/formatter/duration_extractor'
|
5
|
+
require 'json'
|
6
|
+
require 'qat/logger'
|
7
|
+
require 'qat/formatter/loggable'
|
8
|
+
require_relative '../times'
|
9
|
+
|
10
|
+
module QAT
|
11
|
+
# Namespace for QAT Reporter
|
12
|
+
module Reporter
|
13
|
+
# Namespace for custom Cucumber formatters and helpers.
|
14
|
+
#@since 6.1.7
|
15
|
+
module Formatter
|
16
|
+
# Namespace for Time Measurements formatter
|
17
|
+
#@since 6.1.7
|
18
|
+
class TimeMeasurements
|
19
|
+
include ::Cucumber::Formatter::Io
|
20
|
+
include ::Cucumber::Formatter::Duration
|
21
|
+
|
22
|
+
def initialize(runtime, path_or_io, options)
|
23
|
+
@io = ensure_io(path_or_io)
|
24
|
+
@options = options
|
25
|
+
@json_content = []
|
26
|
+
end
|
27
|
+
|
28
|
+
#@api private
|
29
|
+
def before_feature(feature)
|
30
|
+
@in_test_cases = false
|
31
|
+
@current_feature = feature
|
32
|
+
@current_feature_timestamp = Time.now.strftime("%FT%T%z")
|
33
|
+
@outline_tags = []
|
34
|
+
@current_feature_info = {
|
35
|
+
feature: @current_feature,
|
36
|
+
tags: [],
|
37
|
+
timestamp: @current_feature_timestamp,
|
38
|
+
scenarios: []
|
39
|
+
}
|
40
|
+
|
41
|
+
@outline_scenario_info = {
|
42
|
+
name: [],
|
43
|
+
tags: [],
|
44
|
+
timestamp: [],
|
45
|
+
test_runs: []
|
46
|
+
}
|
47
|
+
end
|
48
|
+
|
49
|
+
#@api private
|
50
|
+
def feature_name(*_)
|
51
|
+
@in_test_cases = true
|
52
|
+
end
|
53
|
+
|
54
|
+
#@api private
|
55
|
+
def tag_name(tag_name)
|
56
|
+
@test_id = tag_name.to_s
|
57
|
+
@current_feature_info[:tags] << tag_name unless @in_test_cases
|
58
|
+
|
59
|
+
if @in_test_cases
|
60
|
+
if @current_scenario.is_a?(::Cucumber::Core::Ast::ScenarioOutline)
|
61
|
+
@outline_tags << tag_name
|
62
|
+
else
|
63
|
+
@current_scenario_info[:tags] << tag_name
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
#@api private
|
69
|
+
def before_test_case(test_case)
|
70
|
+
@current_scenario = test_case.source[1]
|
71
|
+
@current_scenario_timestamp = Time.now.strftime("%FT%T%z")
|
72
|
+
|
73
|
+
unless @current_scenario.is_a?(::Cucumber::Core::Ast::ScenarioOutline)
|
74
|
+
@current_scenario_info = {
|
75
|
+
name: @current_scenario,
|
76
|
+
tags: [],
|
77
|
+
timestamp: @current_scenario_timestamp,
|
78
|
+
test_runs: []
|
79
|
+
}
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
#@api private
|
84
|
+
def before_outline_table(*_)
|
85
|
+
@outline = true
|
86
|
+
@outline_scenario_info = {
|
87
|
+
name: @current_scenario,
|
88
|
+
tags: [],
|
89
|
+
timestamp: @current_scenario_timestamp,
|
90
|
+
test_runs: []
|
91
|
+
}
|
92
|
+
end
|
93
|
+
|
94
|
+
#@api private
|
95
|
+
def after_test_case(_, status)
|
96
|
+
test_run_id = QAT[:current_test_run_id]
|
97
|
+
measurements = QAT::Reporter::Times.get_measures rescue []
|
98
|
+
|
99
|
+
test_run_info = {
|
100
|
+
id: test_run_id,
|
101
|
+
timestamp: QAT[:test_start_timestamp]&.strftime("%FT%T%z"),
|
102
|
+
measurements: []
|
103
|
+
}
|
104
|
+
|
105
|
+
measurements.each do |id, measure|
|
106
|
+
if id
|
107
|
+
minutes, seconds = measure[:duration].divmod(60)
|
108
|
+
test_run_info[:measurements] << {
|
109
|
+
id: id,
|
110
|
+
name: measure[:name],
|
111
|
+
timestamp: measure[:start].strftime("%FT%T%z"),
|
112
|
+
time: {
|
113
|
+
secs: measure[:duration],
|
114
|
+
human: "#{minutes}m #{'%02.0f' % seconds}s"
|
115
|
+
}
|
116
|
+
}
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
if @current_scenario.is_a?(::Cucumber::Core::Ast::ScenarioOutline)
|
121
|
+
@outline_scenario_info[:test_runs] << test_run_info
|
122
|
+
else
|
123
|
+
@current_scenario_info[:test_runs] << test_run_info
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
#@api private
|
128
|
+
def after_examples_array(*_)
|
129
|
+
@outline_scenario_info[:tags] = @outline_tags
|
130
|
+
@current_feature_info[:scenarios] << @outline_scenario_info
|
131
|
+
@outline = true
|
132
|
+
@outline_tags = []
|
133
|
+
end
|
134
|
+
|
135
|
+
#@api private
|
136
|
+
def after_feature_element(*_)
|
137
|
+
#After outline run, here cucumber changes for non outline, flag needed for outlines scenarios
|
138
|
+
if @outline == true
|
139
|
+
@outline = false
|
140
|
+
else
|
141
|
+
@current_feature_info[:scenarios] << @current_scenario_info
|
142
|
+
end
|
143
|
+
@in_test_cases = true
|
144
|
+
end
|
145
|
+
|
146
|
+
#@api private
|
147
|
+
def after_feature(*_)
|
148
|
+
@indexes = []
|
149
|
+
@indexes_test_runs = []
|
150
|
+
@scenarios = @current_feature_info[:scenarios]
|
151
|
+
|
152
|
+
@scenarios.each_with_index do |key, value|
|
153
|
+
test_run = key[:test_runs]
|
154
|
+
#Verifies if exist measures in a test_run
|
155
|
+
test_run.each_with_index do |key, value|
|
156
|
+
if key[:measurements].empty?
|
157
|
+
@indexes << value
|
158
|
+
end
|
159
|
+
end
|
160
|
+
#Deletes the empty measures
|
161
|
+
@indexes.reverse!.each do |v|
|
162
|
+
test_run.delete_at(v)
|
163
|
+
end
|
164
|
+
#Verifies if exist test_runs in a scenarios
|
165
|
+
if key[:test_runs].empty?
|
166
|
+
@indexes_test_runs << value
|
167
|
+
end
|
168
|
+
end
|
169
|
+
#Delete empty test runs:
|
170
|
+
@indexes_test_runs.reverse!.each do |v|
|
171
|
+
@current_feature_info[:scenarios].delete_at(v)
|
172
|
+
end
|
173
|
+
|
174
|
+
@json_content << @current_feature_info unless @scenarios.empty?
|
175
|
+
end
|
176
|
+
|
177
|
+
#@api private
|
178
|
+
def after_features(*_)
|
179
|
+
publish_result
|
180
|
+
end
|
181
|
+
|
182
|
+
private
|
183
|
+
|
184
|
+
# Writes results to a JSON file
|
185
|
+
def publish_result
|
186
|
+
@io.puts(JSON.pretty_generate(@json_content))
|
187
|
+
end
|
188
|
+
end
|
189
|
+
end
|
190
|
+
end
|
191
|
+
end
|
@@ -1,3 +1,6 @@
|
|
1
|
+
warn "[WARN] DEPRECATED: QAT::Reporter::Formatters::AsciiTable will be removed in a 7.0 version, please use QAT::Reporter::Helpers::AsciiTable"
|
2
|
+
require_relative '../helpers/ascii_table'
|
3
|
+
|
1
4
|
module QAT
|
2
5
|
module Reporter
|
3
6
|
# Namespace for custom Report output formatters
|
@@ -5,50 +8,7 @@ module QAT
|
|
5
8
|
module Formatters
|
6
9
|
# Namespace for AsciiTable formatter
|
7
10
|
#@since 3.1.0
|
8
|
-
|
9
|
-
|
10
|
-
attr_reader :content
|
11
|
-
|
12
|
-
def initialize(content)
|
13
|
-
@content = content
|
14
|
-
end
|
15
|
-
|
16
|
-
def to_s
|
17
|
-
return @ascii if @ascii
|
18
|
-
|
19
|
-
# conver to 2D array
|
20
|
-
table = set_table(content)
|
21
|
-
widths = calculate_widths(table)
|
22
|
-
|
23
|
-
# header separator
|
24
|
-
table.insert(1, widths.map { |n| '-' * n })
|
25
|
-
|
26
|
-
format = widths.collect { |n| "%-#{n}s" }.join(" | ")
|
27
|
-
|
28
|
-
@ascii ||= table.map do |line|
|
29
|
-
sprintf "| #{format} |\n", *line
|
30
|
-
end.join
|
31
|
-
end
|
32
|
-
|
33
|
-
private
|
34
|
-
|
35
|
-
def set_table(content)
|
36
|
-
[content.first.keys] + content.map(&:values)
|
37
|
-
end
|
38
|
-
|
39
|
-
def calculate_widths(table)
|
40
|
-
widths ||= []
|
41
|
-
table.each do |line|
|
42
|
-
col_index = 0
|
43
|
-
line.each do |col|
|
44
|
-
col = col.to_s
|
45
|
-
widths[col_index] = (widths[col_index] && widths[col_index] > col.length) ? widths[col_index] : col.length
|
46
|
-
col_index += 1
|
47
|
-
end
|
48
|
-
end
|
49
|
-
widths
|
50
|
-
end
|
51
|
-
end
|
11
|
+
AsciiTable = QAT::Reporter::Helpers::AsciiTable
|
52
12
|
end
|
53
13
|
end
|
54
14
|
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
module QAT
|
2
|
+
module Reporter
|
3
|
+
# Namespace for custom Report output formatters
|
4
|
+
#@since 6.1.7
|
5
|
+
module Helpers
|
6
|
+
# Namespace for AsciiTable formatter
|
7
|
+
#@since 6.1.7
|
8
|
+
class AsciiTable
|
9
|
+
|
10
|
+
attr_reader :content
|
11
|
+
|
12
|
+
def initialize(content)
|
13
|
+
@content = content
|
14
|
+
end
|
15
|
+
|
16
|
+
def to_s
|
17
|
+
return @ascii if @ascii
|
18
|
+
|
19
|
+
# conver to 2D array
|
20
|
+
table = set_table(content)
|
21
|
+
widths = calculate_widths(table)
|
22
|
+
|
23
|
+
# header separator
|
24
|
+
table.insert(1, widths.map { |n| '-' * n })
|
25
|
+
|
26
|
+
format = widths.collect { |n| "%-#{n}s" }.join(" | ")
|
27
|
+
|
28
|
+
@ascii ||= table.map do |line|
|
29
|
+
sprintf "| #{format} |\n", *line
|
30
|
+
end.join
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def set_table(content)
|
36
|
+
[content.first.keys] + content.map(&:values)
|
37
|
+
end
|
38
|
+
|
39
|
+
def calculate_widths(table)
|
40
|
+
widths ||= []
|
41
|
+
table.each do |line|
|
42
|
+
col_index = 0
|
43
|
+
line.each do |col|
|
44
|
+
col = col.to_s
|
45
|
+
widths[col_index] = (widths[col_index] && widths[col_index] > col.length) ? widths[col_index] : col.length
|
46
|
+
col_index += 1
|
47
|
+
end
|
48
|
+
end
|
49
|
+
widths
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module QAT
|
2
|
+
module Reporter
|
3
|
+
# namespace for time report measures
|
4
|
+
module Helpers
|
5
|
+
# Namespace for Times Helpers
|
6
|
+
module TimeFormat
|
7
|
+
# Gets a human formatted time
|
8
|
+
# @param time [Time] measure name
|
9
|
+
# @return [Time]
|
10
|
+
def human_formatted_time(time)
|
11
|
+
::Time.at(time).utc.strftime("%Mm %Ss")
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -1,16 +1,12 @@
|
|
1
|
+
warn "[WARN] DEPRECATED: QAT::Reporter::Times::Helpers will be removed in a 7.0 version, please use QAT::Reporter::Helpers::TimeFormat"
|
2
|
+
require_relative '../helpers/time_format'
|
3
|
+
|
1
4
|
module QAT
|
2
5
|
module Reporter
|
3
6
|
# namespace for time report measures
|
4
7
|
class Times
|
5
8
|
# Namespace for Times Helpers
|
6
|
-
|
7
|
-
# Gets a human formatted time
|
8
|
-
# @param time [Time] measure name
|
9
|
-
# @return [Time]
|
10
|
-
def human_formatted_time(time)
|
11
|
-
::Time.at(time).utc.strftime("%Mm %Ss")
|
12
|
-
end
|
13
|
-
end
|
9
|
+
Helpers = QAT::Reporter::Helpers::TimeFormat
|
14
10
|
end
|
15
11
|
end
|
16
12
|
end
|
@@ -1,6 +1,5 @@
|
|
1
1
|
require 'qat/logger'
|
2
|
-
require_relative 'helpers'
|
3
|
-
require_relative '../formatters/ascii_table'
|
2
|
+
require_relative '../helpers'
|
4
3
|
|
5
4
|
module QAT
|
6
5
|
module Reporter
|
@@ -9,7 +8,7 @@ module QAT
|
|
9
8
|
# Namespace for Times Report outputs
|
10
9
|
module Report
|
11
10
|
include QAT::Logger
|
12
|
-
extend Helpers
|
11
|
+
extend QAT::Reporter::Helpers::TimeFormat
|
13
12
|
|
14
13
|
# Builds an ascii table time report for console output
|
15
14
|
# @return [String]
|
@@ -24,7 +23,7 @@ module QAT
|
|
24
23
|
}
|
25
24
|
end
|
26
25
|
|
27
|
-
QAT::Reporter::
|
26
|
+
QAT::Reporter::Helpers::AsciiTable.new(table_data).to_s
|
28
27
|
else
|
29
28
|
"No time measure was recorded!"
|
30
29
|
end
|
data/lib/qat/reporter/times.rb
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
require 'qat/logger'
|
2
2
|
require 'qat/cucumber'
|
3
3
|
require 'qat/core_ext/object/deep_compact'
|
4
|
-
require_relative '
|
5
|
-
require_relative 'times/report'
|
4
|
+
require_relative 'helpers'
|
6
5
|
require_relative 'hooks/time_reporter'
|
7
6
|
|
8
7
|
module QAT
|
@@ -10,7 +9,7 @@ module QAT
|
|
10
9
|
# namespace for time report measures
|
11
10
|
class Times
|
12
11
|
include QAT::Logger
|
13
|
-
extend Helpers
|
12
|
+
extend QAT::Reporter::Helpers::TimeFormat
|
14
13
|
|
15
14
|
# Starts a time measure
|
16
15
|
# @param loading_name [String] measure name
|
data/lib/qat/reporter/version.rb
CHANGED
data/lib/qat/reporter.rb
ADDED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: qat-reporter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 6.1.
|
4
|
+
version: 6.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- QAT
|
@@ -84,7 +84,14 @@ files:
|
|
84
84
|
- lib/qat/formatter/json.rb
|
85
85
|
- lib/qat/formatter/req_coverage.rb
|
86
86
|
- lib/qat/formatter/time_measurements.rb
|
87
|
+
- lib/qat/reporter.rb
|
88
|
+
- lib/qat/reporter/formatter/json.rb
|
89
|
+
- lib/qat/reporter/formatter/req_coverage.rb
|
90
|
+
- lib/qat/reporter/formatter/time_measurements.rb
|
87
91
|
- lib/qat/reporter/formatters/ascii_table.rb
|
92
|
+
- lib/qat/reporter/helpers.rb
|
93
|
+
- lib/qat/reporter/helpers/ascii_table.rb
|
94
|
+
- lib/qat/reporter/helpers/time_format.rb
|
88
95
|
- lib/qat/reporter/hooks/time_reporter.rb
|
89
96
|
- lib/qat/reporter/times.rb
|
90
97
|
- lib/qat/reporter/times/helpers.rb
|