qat-reporter 6.1.0 → 6.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fe672befb4141493780885ad000c091f3305bd7218f602f5230313c5250135e8
4
- data.tar.gz: 576f6a3ac4e7fd93670f01b63f4d6e31371e4d33e1c0535c273e8ff087122d7d
3
+ metadata.gz: aff09985c21836c062c08f0b76b62e6db193fe4217083ce76aaca9da5225eb72
4
+ data.tar.gz: 0fa22c9f40ff66cee9f2129c14efce9f8a8e62d875978900b4746866d016ea2e
5
5
  SHA512:
6
- metadata.gz: 0ad43167d0d7b721041d3fac69a42f554a73d718f6e6ce39af2bdabbfa1d6e0661356c057cc290562eb921a4a3a2aea75b31fbbfc96c2e327adb0aea479cf84d
7
- data.tar.gz: e132a8cf3460143a2cd8e0345b738a16fefcc807933d641f17783087ca36a5b0aebe988bb599f7d68d58b202f82d05d341b28d17abe3f14dac0aa641ac9a1fa0
6
+ metadata.gz: a9f09816f53cabb02a0b498a8098b6892b8edd7933d42664ff740f694d51a98fcaa6d0936cf763cb2762cb254f56801fda964d1979c2367685d8caa339b797c1
7
+ data.tar.gz: f479e89276f78ae1bd998afafb0cbcbce3ce27e7eb482de7f2b9a5b0bd157d731842c3628efee8e1ae5a62acfa75e15dbb1b0b57aca690b17c9c1c60fc5c2628
@@ -3,7 +3,6 @@ require 'cucumber/formatter/io'
3
3
  require 'cucumber/formatter/duration'
4
4
  require 'cucumber/formatter/duration_extractor'
5
5
  require 'json'
6
- require 'fileutils'
7
6
  require 'qat/logger'
8
7
  require 'qat/formatter/loggable'
9
8
  require_relative '../../qat/reporter/times'
@@ -13,29 +12,36 @@ module QAT
13
12
  #@since 0.1.0
14
13
  module Formatter
15
14
  # Namespace for Time Measurements formatter
16
- #@since 1.0.0
15
+ #@since 6.2.0
17
16
  class TimeMeasurements
18
17
  include ::Cucumber::Formatter::Io
19
18
  include ::Cucumber::Formatter::Duration
20
- include QAT::Formatter::Loggable
21
- include QAT::Logger
22
19
 
23
- #@api private
24
20
  def initialize(runtime, path_or_io, options)
25
- @io = ensure_io(path_or_io)
26
- @options = options
27
- @test_results = []
28
-
29
- # ensure_outputter 'TimeMeasurements' unless options[:dry_run]
21
+ @io = ensure_io(path_or_io)
22
+ @options = options
23
+ @json_content = []
30
24
  end
31
25
 
32
26
  #@api private
33
- def before_feature(*_)
34
- @feature_requirement_ids = []
35
- @test_requirement_ids = []
36
- @in_test_cases = false
37
- @row_counter = 0
38
- @flag_tag = nil
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_run: []
44
+ }
39
45
  end
40
46
 
41
47
  #@api private
@@ -45,76 +51,121 @@ module QAT
45
51
 
46
52
  #@api private
47
53
  def tag_name(tag_name)
48
- # @test_id = tag_name.to_s
49
- # requirement_id = tag_name.to_s.split('#')[1] if tag_name.match(/@user_story#(\d+)/)
50
- # if @in_test_cases
51
- # @test_requirement_ids << requirement_id
52
- # else
53
- # @feature_requirement_ids << requirement_id
54
- # end
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
55
64
  end
56
65
 
57
66
  #@api private
58
67
  def before_test_case(test_case)
59
- @current_feature = test_case.source[0]
60
68
  @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
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_run: []
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_run: []
89
+ }
65
90
  end
66
91
 
67
92
  #@api private
68
93
  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
- duration = ::Cucumber::Formatter::DurationExtractor.new(status).result_duration
94
+ duration = ::Cucumber::Formatter::DurationExtractor.new(status).result_duration
78
95
  human_duration = format_duration(duration)
79
96
 
80
- test_id = QAT[:current_test_id]
97
+
81
98
  test_run_id = QAT[:current_test_run_id]
82
99
  begin
83
100
  measurements = QAT::Reporter::Times.generate_time_report QAT[:current_test_id]
84
101
  rescue
85
- measurements = nil
102
+ measurements = []
86
103
  end
87
104
 
88
- unless measurements.nil?
105
+ unless measurements == [] || measurements == {}
89
106
  measurements.each do |id, measure|
90
- @measurement_id = id
107
+ @measurement_id = id
91
108
  @measurement_name = measure[:name]
92
109
  end
93
110
 
94
111
  unless @measurement_id.nil?
95
- @test_results <<
96
- {
97
- feature: @current_feature,
98
- scenario: @current_scenario,
99
- status: test_status,
100
- test_id: test_id,
101
- test_run_id: test_run_id,
112
+ test_run_info = {
113
+ id: test_run_id,
114
+ timestamp: Time.now.strftime("%FT%T%z"),
102
115
  measurements: [
103
- id: @measurement_id,
104
- name: @measurement_name,
105
- time: {
106
- duration: duration,
107
- human_duration: human_duration
108
- }
116
+ {
117
+ id: @measurement_id,
118
+ name: @measurement_name,
119
+ timestamp: Time.now.strftime("%FT%T%z"),
120
+ time: {
121
+ secs: duration,
122
+ human: human_duration
123
+ }
124
+ }
125
+ ]
126
+ }
127
+
128
+ if @current_scenario.is_a?(::Cucumber::Core::Ast::ScenarioOutline)
129
+ @outline_scenario_info[:test_run] << test_run_info
130
+ else
131
+ @current_scenario_info[:test_run] << test_run_info
132
+ end
133
+ end
134
+ end
135
+ end
109
136
 
110
- ]
137
+ #@api private
138
+ def after_examples_array(*_)
139
+ @outline_scenario_info[:tags] = @outline_tags
140
+ @current_feature_info[:scenarios] << @outline_scenario_info
141
+ @outline = true
142
+ @outline_tags = []
143
+ end
111
144
 
112
- }
113
- end
145
+ #@api private
146
+ def after_feature_element(*_)
147
+ #After outline run, here cucumber changes for non outline, flag needed for outlines scenarios
148
+ if @outline == true
149
+ @outline = false
150
+ else
151
+ @current_feature_info[:scenarios] << @current_scenario_info
114
152
  end
153
+ @in_test_cases = true
154
+ end
115
155
 
116
- @test_requirement_ids = [] unless @current_scenario.is_a?(::Cucumber::Core::Ast::ScenarioOutline)
117
- @flag_tag = @test_id if @flag_tag != @test_id
156
+ #@api private
157
+ def after_feature(*_)
158
+ @indexes = []
159
+ @scenarios = @current_feature_info[:scenarios]
160
+ @scenarios.each_with_index do |key, value|
161
+ if key[:test_run].empty?
162
+ @indexes << value
163
+ end
164
+ end
165
+ @indexes.reverse!.each do |v|
166
+ @current_feature_info[:scenarios].delete_at(v)
167
+ end
168
+ @json_content << @current_feature_info unless @scenarios.empty?
118
169
  end
119
170
 
120
171
  #@api private
@@ -122,13 +173,11 @@ module QAT
122
173
  publish_result
123
174
  end
124
175
 
125
-
126
176
  private
127
177
 
128
178
  # Writes results to a JSON file
129
179
  def publish_result
130
- content = @test_results
131
- @io.puts(JSON.pretty_generate(content))
180
+ @io.puts(JSON.pretty_generate(@json_content))
132
181
  end
133
182
  end
134
183
  end
@@ -3,6 +3,6 @@ module QAT
3
3
  # Namespace for QAT Reporter
4
4
  module Reporter
5
5
  # Represents QAT Reporter's version
6
- VERSION = '6.1.0'
6
+ VERSION = '6.1.1'
7
7
  end
8
8
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: qat-reporter
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.1.0
4
+ version: 6.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - QAT
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-08-07 00:00:00.000000000 Z
11
+ date: 2019-09-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: qat-cucumber
@@ -110,7 +110,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
110
110
  - !ruby/object:Gem::Version
111
111
  version: '0'
112
112
  requirements: []
113
- rubygems_version: 3.0.4
113
+ rubygems_version: 3.0.6
114
114
  signing_key:
115
115
  specification_version: 4
116
116
  summary: Utility for Test Reports.