qat-reporter-xray 6.0.1 → 7.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c5fe00eb7f14dfdceb84146458b6a0719afff762e66e104490b396bb7a4ad341
4
- data.tar.gz: 4dd113a99f6e47cd2077f788a234a526c852f26ef983e9a8d744f85577d1aab8
3
+ metadata.gz: 50cce4d0b879eda243798350001c094c8b509bad2c0ce5347a6ac224edf69e45
4
+ data.tar.gz: 9697c159a902ec243174c158b8b889541ceecb923097e8f78688594709981b68
5
5
  SHA512:
6
- metadata.gz: e23a8ebd0122392ee14733cc2e992f27dbc82da9a9d1c2d08f8dcc6e8f5b34fea62fd19cb55db1f8695f86e2b1d34e7549bd93b0e81ad24f5a31c5023ff019b4
7
- data.tar.gz: bf213535ec65993c3c8e376ee077ac3b9f12def3a7799e76d16b8c5b6d0f6aafe074ab7ae8368cc8bdef869ddba4cacc68a2134b06e7aedddecf28426e70af87
6
+ metadata.gz: 58f836f2807350c022ffd8f4142ac5f4d62887c5fd0196389dd74cf39a97a57a9808ad04ca1b6d8fcaba6aba0f12b737b29711c23344b136b4d0f4ebdd958538
7
+ data.tar.gz: c0edadc3b24bc48aa76de0b5abfc2e74c674cfa1d2359f1766a1513cc7cb5e30160cca299e00c3b1b213e080d6d15131bf925cf614476c0f00ffab9a808605a2
@@ -1,3 +1 @@
1
- require_relative 'core_ext/result'
2
- require_relative 'core_ext/formatter/html'
3
- require_relative 'core_ext/formatter/junit'
1
+ require_relative 'core_ext/result'
@@ -6,6 +6,7 @@ require 'time'
6
6
  require 'base64'
7
7
  require_relative '../reporter/xray/config'
8
8
  require_relative '../reporter/xray/test_execution'
9
+ require 'qat/formatter/helper'
9
10
 
10
11
  module QAT
11
12
  # Namespace for custom Cucumber formatters and helpers.
@@ -16,12 +17,17 @@ module QAT
16
17
  class Xray
17
18
  include ::Cucumber::Formatter::Io
18
19
  include QAT::Logger
19
-
20
- #@api private
21
- def initialize(runtime, path_or_io, options)
22
- @io = ensure_io(path_or_io)
23
- @options = options
24
- @tests = []
20
+ include QAT::Formatter::Helper
21
+
22
+ def initialize(config)
23
+ @config = config
24
+ @io = ensure_io(config.out_stream, config.error_stream)
25
+ @ast_lookup = ::Cucumber::Formatter::AstLookup.new(config)
26
+ @feature_hashes = []
27
+ config.on_event :test_case_started, &method(:on_test_case_started)
28
+ config.on_event :test_case_finished, &method(:on_test_case_finished)
29
+ config.on_event :test_run_finished, &method(:on_test_run_finished)
30
+ @tests = []
25
31
  end
26
32
 
27
33
  #@api private
@@ -30,22 +36,32 @@ module QAT
30
36
  end
31
37
 
32
38
  #@api private
33
- def before_test_case(test_case)
34
- @current_scenario = test_case.source[1]
39
+ def on_test_case_started(event)
40
+ return if @config.dry_run?
41
+ @row_number = nil
42
+ test_case = event.test_case
43
+ build(test_case, @ast_lookup)
44
+ @current_scenario = @scenario
35
45
 
36
46
  @exception = nil
37
47
 
38
48
  @start_time = Time.now
39
49
  @evidences = []
40
50
  @file_counter = 0
51
+ @current_scenario[:tags].each do |tag|
52
+ tag_name tag
53
+ end
54
+
41
55
  end
42
56
 
43
57
  #@api private
44
- def after_test_case(_, status)
58
+ def on_test_case_finished event
59
+ return if @config.dry_run?
60
+ _test_case, result = *event.attributes
45
61
  # When jira type is cloud the test result string must be different (accordingly with xray api)
46
- test_status = if status.is_a? ::Cucumber::Core::Test::Result::Passed
62
+ test_status = if result.passed?
47
63
  jira_type == 'cloud' ? 'PASSED' : 'PASS'
48
- elsif status.is_a? ::Cucumber::Core::Test::Result::Failed
64
+ elsif result.failed?
49
65
  jira_type == 'cloud' ? 'FAILED' : 'FAIL'
50
66
  else
51
67
  'NO RUN'
@@ -53,10 +69,10 @@ module QAT
53
69
 
54
70
  @end_time = Time.now
55
71
 
56
- comment = status.respond_to?(:exception) ? build_exception(status.exception) : ''
72
+ comment = result.respond_to?(:exception) ? build_exception(result.exception) : ''
57
73
 
58
74
  log.warn 'Jira ID is not defined!' unless @test_jira_id
59
- if @current_scenario.is_a? ::Cucumber::Core::Ast::ScenarioOutline
75
+ if @examples_values
60
76
  save_current_scenario_outline(test_status, comment)
61
77
  else
62
78
  save_current_scenario(test_status, comment)
@@ -64,12 +80,15 @@ module QAT
64
80
 
65
81
  end
66
82
 
67
- #@api private
68
- def after_features(*_)
83
+
84
+ def on_test_run_finished _event
85
+ return if @config.dry_run?
69
86
  publish_result
70
87
  end
71
88
 
72
- def embed(src, mime_type, label)
89
+
90
+
91
+ def attach(src, mime_type)
73
92
 
74
93
 
75
94
  data = if File.file?(src)
@@ -86,10 +105,8 @@ module QAT
86
105
 
87
106
  file_name = if File.file?(src)
88
107
  File.basename(src)
89
- elsif label.to_s.empty?
90
- "file_#{@file_counter += 1}.#{ext}"
91
108
  else
92
- "#{label}.#{ext}"
109
+ "#{src}.#{ext}"
93
110
  end
94
111
 
95
112
  @evidences << { data: data, filename: file_name, contentType: mime_type }
@@ -1,95 +1,57 @@
1
1
  require 'cucumber/formatter/io'
2
2
  require 'json'
3
+ require 'qat/formatter/test_ids'
4
+ require 'qat/formatter/helper'
3
5
 
4
6
  module QAT
5
7
  module Formatter
6
8
  class Xray
7
- class TestIds
9
+ class TestIds <QAT::Formatter::TestIds
8
10
  include Cucumber::Formatter::Io
11
+ include QAT::Formatter::Helper
9
12
 
10
- def initialize(runtime, path_or_io, options)
11
- @io = ensure_io(path_or_io)
12
- @tags = []
13
- @scenario_tags = []
13
+ def initialize(config)
14
+ @config = config
14
15
  @no_test_id = {}
15
16
  @max_test_id = 0
16
17
  @duplicate_test_ids = {}
17
18
  @test_id_mapping = {}
18
- @options = options
19
+ @io = ensure_io(config.out_stream, config.error_stream)
20
+ @ast_lookup = ::Cucumber::Formatter::AstLookup.new(@config)
21
+ config.on_event :test_case_started, &method(:on_test_case_started)
22
+ config.on_event :test_run_finished, &method(:on_test_run_finished)
19
23
  end
20
24
 
21
- def before_feature(feature)
22
- @in_scenarios = false
23
- end
24
-
25
- def tag_name(tag_name)
26
- @scenario_tags << tag_name if @in_scenarios
27
- end
28
-
29
- def after_tags(tags)
30
- @in_scenarios = true unless @in_scenarios
31
- end
32
25
 
33
- def scenario_name(keyword, name, file_colon_line, source_indent)
34
- if @scenario_tags.any? { |tag| tag.match(/@id:(\d+)/) }
35
- id = @scenario_tags.map { |tag| tag.match(/@id:(\d+)/) }.compact.first.captures.first.to_i
26
+ ###Override because of tag condition
27
+ def scenario_name
28
+ path = "#{@current_feature[:uri]}:#{@scenario[:line]}"
29
+ scenario_tags= @scenario[:tags]
30
+ if scenario_tags.any? { |tag| tag.match(/@id:(\d+)/) }
31
+ id = scenario_tags.map { |tag| tag.match(/@id:(\d+)/) }.compact.first.captures.first.to_i
36
32
  @max_test_id = id if id > @max_test_id
37
33
 
38
- test_id_info = { name: name,
39
- path: file_colon_line }
34
+ test_id_info = { name: @scenario[:name],
35
+ path: path}
40
36
 
41
37
  if @test_id_mapping[id]
42
38
  if @duplicate_test_ids[id]
43
- @duplicate_test_ids[id] << test_id_info
39
+ @duplicate_test_ids[id].find do |dup|
40
+ @exist = true if dup[:path]== test_id_info[:path]
41
+ end
42
+ @duplicate_test_ids[id] << test_id_info unless @exist
44
43
  else
45
- @duplicate_test_ids[id] = [@test_id_mapping[id], test_id_info]
44
+ @duplicate_test_ids[id] = [@test_id_mapping[id], test_id_info] unless @test_id_mapping[id][:path] == test_id_info[:path]
46
45
  end
47
46
  else
48
47
  @test_id_mapping[id] = test_id_info
49
48
  end
50
-
51
49
  else
52
- @no_test_id[name] = file_colon_line unless @scenario_tags.include?('@dummy_test')
50
+ @no_test_id[@scenario[:name]] = path unless scenario_tags.include?('@dummy_test')
53
51
  end
54
- @scenario_tags = []
55
- end
56
-
57
- def after_features(features)
58
- publish_result
59
- @io.flush
52
+ @scenario[:tags] = []
60
53
  end
61
54
 
62
- private
63
-
64
- def publish_result
65
- content = {
66
- max: @max_test_id,
67
- untagged: @no_test_id,
68
- mapping: Hash[@test_id_mapping.sort],
69
- duplicate: Hash[@duplicate_test_ids.sort]
70
- }
71
-
72
- if @duplicate_test_ids.any?
73
- dups_info = @duplicate_test_ids.map do |id, dups|
74
- text = dups.map { |dup| "Scenario: #{dup[:name]} - #{dup[:path]}" }.join("\n")
75
- "TEST ID #{id}:\n#{text}\n"
76
- end
77
-
78
- duplicates_info = <<-TXT.gsub(/^\s*/, '')
79
- ------------------------------------
80
- Duplicate test ids found!
81
- ------------------------------------
82
- #{dups_info.join("\n")}
83
- TXT
84
- puts duplicates_info
85
- end
86
-
87
- @io.puts(content.to_json({
88
- indent: ' ',
89
- space: ' ',
90
- object_nl: "\n"
91
- }))
92
- end
93
55
  end
94
56
  end
95
57
  end
@@ -60,6 +60,7 @@ namespace :qat do
60
60
  report.tag_untagged!
61
61
  end
62
62
 
63
+
63
64
  desc 'Generate features zip file to import in Xray'
64
65
  task :zip_features do
65
66
  require 'zip'
@@ -5,7 +5,7 @@ module QAT
5
5
  # Namespace for QAT Reporter's Xray integrations
6
6
  class Xray
7
7
  # Represents QAT Reporter's Xray integrations' version
8
- VERSION = '6.0.1'
8
+ VERSION = '7.0.0'
9
9
  end
10
10
  end
11
11
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: qat-reporter-xray
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.0.1
4
+ version: 7.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - QAT
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-05-04 00:00:00.000000000 Z
11
+ date: 2021-05-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: vcr
@@ -76,42 +76,42 @@ dependencies:
76
76
  requirements:
77
77
  - - "~>"
78
78
  - !ruby/object:Gem::Version
79
- version: '6.0'
79
+ version: 8.0.0
80
80
  type: :development
81
81
  prerelease: false
82
82
  version_requirements: !ruby/object:Gem::Requirement
83
83
  requirements:
84
84
  - - "~>"
85
85
  - !ruby/object:Gem::Version
86
- version: '6.0'
86
+ version: 8.0.0
87
87
  - !ruby/object:Gem::Dependency
88
88
  name: qat-cucumber
89
89
  requirement: !ruby/object:Gem::Requirement
90
90
  requirements:
91
91
  - - "~>"
92
92
  - !ruby/object:Gem::Version
93
- version: '6.0'
93
+ version: 7.0.3
94
94
  type: :development
95
95
  prerelease: false
96
96
  version_requirements: !ruby/object:Gem::Requirement
97
97
  requirements:
98
98
  - - "~>"
99
99
  - !ruby/object:Gem::Version
100
- version: '6.0'
100
+ version: 7.0.3
101
101
  - !ruby/object:Gem::Dependency
102
102
  name: qat-logger
103
103
  requirement: !ruby/object:Gem::Requirement
104
104
  requirements:
105
- - - ">="
105
+ - - "~>"
106
106
  - !ruby/object:Gem::Version
107
- version: '0'
107
+ version: 8.0.0
108
108
  type: :runtime
109
109
  prerelease: false
110
110
  version_requirements: !ruby/object:Gem::Requirement
111
111
  requirements:
112
- - - ">="
112
+ - - "~>"
113
113
  - !ruby/object:Gem::Version
114
- version: '0'
114
+ version: 8.0.0
115
115
  - !ruby/object:Gem::Dependency
116
116
  name: rest-client
117
117
  requirement: !ruby/object:Gem::Requirement
@@ -180,7 +180,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
180
180
  requirements:
181
181
  - - "~>"
182
182
  - !ruby/object:Gem::Version
183
- version: '2.3'
183
+ version: '2.5'
184
184
  required_rubygems_version: !ruby/object:Gem::Requirement
185
185
  requirements:
186
186
  - - ">="