qat-reporter-xray-sa 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +674 -0
- data/lib/qat/reporter/xray/config.rb +142 -0
- data/lib/qat/reporter/xray/issue.rb +46 -0
- data/lib/qat/reporter/xray/publisher/base.rb +198 -0
- data/lib/qat/reporter/xray/publisher/cloud.rb +123 -0
- data/lib/qat/reporter/xray/publisher/hosted.rb +54 -0
- data/lib/qat/reporter/xray/publisher.rb +3 -0
- data/lib/qat/reporter/xray/tasks/tests/helpers.rb +112 -0
- data/lib/qat/reporter/xray/tasks/tests/report.rb +47 -0
- data/lib/qat/reporter/xray/tasks/tests.rb +139 -0
- data/lib/qat/reporter/xray/tasks.rb +4 -0
- data/lib/qat/reporter/xray/test.rb +44 -0
- data/lib/qat/reporter/xray/test_execution.rb +77 -0
- data/lib/qat/reporter/xray/version.rb +11 -0
- data/lib/qat/reporter/xray.rb +2 -0
- metadata +148 -0
@@ -0,0 +1,47 @@
|
|
1
|
+
require_relative 'helpers'
|
2
|
+
|
3
|
+
module QAT
|
4
|
+
module Reporter
|
5
|
+
class Xray
|
6
|
+
# namespace for test ids utility methods and objects
|
7
|
+
module Tests
|
8
|
+
# the test id report wrapper
|
9
|
+
class Report
|
10
|
+
include Helpers
|
11
|
+
|
12
|
+
attr_reader :path, :content
|
13
|
+
|
14
|
+
def initialize(path)
|
15
|
+
@path = path
|
16
|
+
@content = JSON.parse(File.read(path))
|
17
|
+
end
|
18
|
+
|
19
|
+
# Returns the report max test id
|
20
|
+
def max_id
|
21
|
+
@max_id ||= @content['max']
|
22
|
+
end
|
23
|
+
|
24
|
+
# Returns the report untagged tests information
|
25
|
+
def untagged
|
26
|
+
@untagged ||= @content['untagged']
|
27
|
+
end
|
28
|
+
|
29
|
+
# Returns the report test id mapping to scenarios information
|
30
|
+
def mapping
|
31
|
+
@mapping ||= @content['mapping']
|
32
|
+
end
|
33
|
+
|
34
|
+
# Returns the report duplicate test id information
|
35
|
+
def duplicate
|
36
|
+
@duplicate ||= @content['duplicate']
|
37
|
+
end
|
38
|
+
|
39
|
+
# Tags all untagged scenario with a test id
|
40
|
+
def tag_untagged!
|
41
|
+
tag_untagged(self)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,139 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
#encoding: utf-8
|
3
|
+
require 'rake/testtask'
|
4
|
+
require 'json'
|
5
|
+
require 'fileutils'
|
6
|
+
require 'awesome_print'
|
7
|
+
require 'fileutils'
|
8
|
+
require 'active_support/core_ext/string/inflections'
|
9
|
+
require_relative 'tests/report'
|
10
|
+
require_relative 'tests/helpers'
|
11
|
+
|
12
|
+
namespace :qat do
|
13
|
+
namespace :reporter do
|
14
|
+
namespace :xray do
|
15
|
+
namespace :tests do
|
16
|
+
# Run a rake task by name
|
17
|
+
def run_task!(task_name)
|
18
|
+
begin
|
19
|
+
Rake::Task["qat:reporter:xray:tests:#{task_name}"].invoke
|
20
|
+
rescue SystemExit => exception
|
21
|
+
exitstatus = exception.status
|
22
|
+
@kernel.exit(exitstatus) unless exitstatus == 0
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
desc 'Generates the test id report in JSON'
|
27
|
+
task :report_test_ids do
|
28
|
+
FileUtils.mkdir('public') unless File.exists?(File.join(Dir.pwd, 'public'))
|
29
|
+
ENV['CUCUMBER_OPTS'] = nil
|
30
|
+
Cucumber::Rake::Task.new('test_ids', 'Generates test ids as tags for tests without test id') do |task|
|
31
|
+
task.bundler = false
|
32
|
+
task.fork = false
|
33
|
+
task.cucumber_opts = ['--no-profile',
|
34
|
+
'--dry-run',
|
35
|
+
'--out', 'public/xray_test_ids.json']
|
36
|
+
end.runner.run
|
37
|
+
end
|
38
|
+
|
39
|
+
desc 'Validates the existing test ids and checks for duplicates'
|
40
|
+
task :validate_test_ids do
|
41
|
+
run_task!('report_test_ids')
|
42
|
+
#read json file
|
43
|
+
file_path = File.realpath(File.join(Dir.pwd, 'public', 'xray_test_ids.json'))
|
44
|
+
report = QAT::Reporter::Xray::Tests::Report.new(file_path)
|
45
|
+
|
46
|
+
exit(1) if report.duplicate.any?
|
47
|
+
end
|
48
|
+
|
49
|
+
desc 'Generates test ids as tags for tests without test id'
|
50
|
+
task :generate_test_ids do
|
51
|
+
run_task!('report_test_ids')
|
52
|
+
#read json file
|
53
|
+
file_path = File.realpath(File.join(Dir.pwd, 'public', 'xray_test_ids.json'))
|
54
|
+
report = QAT::Reporter::Xray::Tests::Report.new(file_path)
|
55
|
+
|
56
|
+
report.tag_untagged!
|
57
|
+
end
|
58
|
+
|
59
|
+
|
60
|
+
desc 'Generate features zip file to import in Xray'
|
61
|
+
task :zip_features do
|
62
|
+
require 'zip'
|
63
|
+
|
64
|
+
file_mask = File.join('features', '**', '*.feature')
|
65
|
+
feature_files = Dir.glob(file_mask)
|
66
|
+
puts feature_files
|
67
|
+
|
68
|
+
zipfile_name = 'features.zip'
|
69
|
+
|
70
|
+
FileUtils.rm_f(zipfile_name) if File.exists?(zipfile_name)
|
71
|
+
|
72
|
+
Zip::File.open(zipfile_name, Zip::File::CREATE) do |zipfile|
|
73
|
+
feature_files.each do |file|
|
74
|
+
zipfile.add(file, file)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
# Validates the import task arguments
|
80
|
+
def validate_import_args(args)
|
81
|
+
[:xray_username, :jira_url, :jira_type, :project_key].each do |key|
|
82
|
+
raise ArgumentError.new "No #{key.to_s.humanize} was provided" unless args[key]
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
desc 'Import Cucumber tests to Xray'
|
87
|
+
task :import_features, [:xray_username, :jira_url, :jira_type, :project_key, :file_path] do |_, args|
|
88
|
+
run_task!('generate_test_ids')
|
89
|
+
run_task!('zip_features')
|
90
|
+
|
91
|
+
require 'qat/reporter/xray'
|
92
|
+
|
93
|
+
file_path = args.delete(:file_path) || 'features.zip'
|
94
|
+
|
95
|
+
validate_import_args(args)
|
96
|
+
project_key = args[:project_key] or raise ArgumentError.new 'No project key was provided'
|
97
|
+
login_credentials = [args[:xray_username], ENV['JIRA_PASSWORD']] or raise ArgumentError.new 'No login credentials were provided'
|
98
|
+
jira_type = args[:jira_type] or raise ArgumentError.new 'No jira type key was provided'
|
99
|
+
jira_url = args[:jira_url] or raise ArgumentError.new 'No jira url key was provided'
|
100
|
+
|
101
|
+
QAT::Reporter::Xray.configure do |c|
|
102
|
+
c.project_key = project_key
|
103
|
+
c.login_credentials = login_credentials
|
104
|
+
c.cloud_xray_api_credentials = login_credentials if jira_type.eql? 'cloud'
|
105
|
+
c.jira_type = jira_type
|
106
|
+
c.jira_url = jira_url
|
107
|
+
end
|
108
|
+
|
109
|
+
QAT::Reporter::Xray::Config.publisher.import_cucumber_tests(project_key, file_path)
|
110
|
+
end
|
111
|
+
|
112
|
+
desc 'Export Xray test scenarios '
|
113
|
+
task :export_xray_test_scenarios, [:xray_username, :jira_url, :jira_type, :project_key, :keys, :filter] do |_, args|
|
114
|
+
|
115
|
+
require 'qat/reporter/xray'
|
116
|
+
|
117
|
+
project_key = args[:project_key] or raise ArgumentError.new 'No project key was provided'
|
118
|
+
login_credentials = [args[:xray_username], ENV['JIRA_PASSWORD']] or raise ArgumentError.new 'No login credentials were provided'
|
119
|
+
jira_type = args[:jira_type] or raise ArgumentError.new 'No jira type was provided'
|
120
|
+
jira_url = args[:jira_url] or raise ArgumentError.new 'No jira url was provided'
|
121
|
+
xray_export_test_filter = args[:filter] or raise ArgumentError.new 'No filter key was provided'
|
122
|
+
xray_export_test_keys = args[:keys] or raise ArgumentError.new 'No test issue key was provided'
|
123
|
+
|
124
|
+
QAT::Reporter::Xray.configure do |c|
|
125
|
+
c.project_key = project_key
|
126
|
+
c.login_credentials = login_credentials
|
127
|
+
c.cloud_xray_api_credentials = login_credentials if jira_type.eql? 'cloud'
|
128
|
+
c.jira_type = jira_type
|
129
|
+
c.jira_url = jira_url
|
130
|
+
c.xray_export_test_filter = xray_export_test_filter
|
131
|
+
c.xray_export_test_keys = xray_export_test_keys
|
132
|
+
end
|
133
|
+
|
134
|
+
QAT::Reporter::Xray::Config.publisher.export_test_scenarios(xray_export_test_keys, xray_export_test_filter)
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'rest-client'
|
2
|
+
require_relative 'issue'
|
3
|
+
|
4
|
+
module QAT
|
5
|
+
module Reporter
|
6
|
+
class Xray
|
7
|
+
# QAT::Reporter::Xray::TestExecution represents a Xray Test Execution object
|
8
|
+
class Test < Issue
|
9
|
+
|
10
|
+
# Creates a Test issue in Jira
|
11
|
+
def create(options = {})
|
12
|
+
data = defaults.merge(options)
|
13
|
+
response = super(data)
|
14
|
+
test_key = JSON.parse(response)['key']
|
15
|
+
puts "Created test with key: '#{test_key}'."
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
def defaults
|
20
|
+
{
|
21
|
+
fields: {
|
22
|
+
project:
|
23
|
+
{
|
24
|
+
key: QAT::Reporter::Xray::Config.project_key
|
25
|
+
},
|
26
|
+
summary: "Execution of automated tests #{Time.now.strftime('%F %T')}",
|
27
|
+
description: 'Creation of automated Test',
|
28
|
+
issuetype: {
|
29
|
+
name: 'Test'
|
30
|
+
},
|
31
|
+
customfield_10200: {
|
32
|
+
value: 'Cucumber'
|
33
|
+
},
|
34
|
+
customfield_10201: {
|
35
|
+
value: 'Scenario'
|
36
|
+
},
|
37
|
+
customfield_10202: 'customfield_10202'
|
38
|
+
}
|
39
|
+
}
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
require 'rest-client'
|
2
|
+
require_relative 'issue'
|
3
|
+
|
4
|
+
module QAT
|
5
|
+
module Reporter
|
6
|
+
class Xray
|
7
|
+
# QAT::Reporter::Xray::TestExecution represents a Xray Test Execution object
|
8
|
+
class TestExecution < Issue
|
9
|
+
|
10
|
+
# Creates a Test Execution issue in Jira
|
11
|
+
def create(options = {})
|
12
|
+
data = test_execution_defaults.merge(options)
|
13
|
+
response = super(data)
|
14
|
+
test_execution_key = JSON.parse(response)['key']
|
15
|
+
puts "Created test execution with key: '#{test_execution_key}', saving in 'XRAY_TEST_EXECUTION' env variable."
|
16
|
+
ENV['XRAY_TEST_EXECUTION'] = test_execution_key
|
17
|
+
end
|
18
|
+
|
19
|
+
# Posts the execution json results in Xray
|
20
|
+
def import_execution_results(execution_results, info = {})
|
21
|
+
puts execution_results
|
22
|
+
if jira_id
|
23
|
+
issue_info = info.merge(default_update_headers(execution_results))
|
24
|
+
issue_info[:testExecutionKey] = jira_id
|
25
|
+
else
|
26
|
+
issue_info = info.merge(default_create_headers(execution_results))
|
27
|
+
end
|
28
|
+
#If no test execution found, Xray will create one automatically
|
29
|
+
QAT::Reporter::Xray::Config.publisher.send_execution_results(issue_info)
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def default_create_headers(execution_results)
|
35
|
+
{
|
36
|
+
info: {
|
37
|
+
summary: "Execution of automated tests #{Time.now.strftime('%F %T')}",
|
38
|
+
description: 'This execution is automatically created when importing execution results from an external source',
|
39
|
+
}.merge(test_execution_info(execution_results))
|
40
|
+
}.merge(execution_results)
|
41
|
+
end
|
42
|
+
|
43
|
+
def default_update_headers(execution_results)
|
44
|
+
{
|
45
|
+
info: test_execution_info(execution_results)
|
46
|
+
}.merge(execution_results)
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_execution_info(execution_results)
|
50
|
+
{
|
51
|
+
startDate: execution_results[:tests].first[:start],
|
52
|
+
finishDate: execution_results[:tests].last[:finish],
|
53
|
+
version: QAT::Reporter::Xray::Config.xray_test_version.to_s,
|
54
|
+
revision: QAT::Reporter::Xray::Config.xray_test_revision.to_s,
|
55
|
+
testEnvironments: [QAT::Reporter::Xray::Config.xray_test_environment]
|
56
|
+
}
|
57
|
+
end
|
58
|
+
|
59
|
+
def test_execution_defaults
|
60
|
+
{
|
61
|
+
fields: {
|
62
|
+
project:
|
63
|
+
{
|
64
|
+
key: QAT::Reporter::Xray::Config.project_key
|
65
|
+
},
|
66
|
+
summary: "Execution of automated tests #{Time.now.strftime('%F %T')}",
|
67
|
+
description: 'Creation of automated Test Execution',
|
68
|
+
issuetype: {
|
69
|
+
name: 'Test Execution'
|
70
|
+
}
|
71
|
+
}
|
72
|
+
}
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
metadata
ADDED
@@ -0,0 +1,148 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: qat-reporter-xray-sa
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- QAT
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2023-07-29 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: vcr
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '5.0'
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 5.0.0
|
23
|
+
type: :development
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '5.0'
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 5.0.0
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: webmock
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '3.6'
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: 3.6.0
|
43
|
+
type: :development
|
44
|
+
prerelease: false
|
45
|
+
version_requirements: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - "~>"
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '3.6'
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: 3.6.0
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: aruba
|
55
|
+
requirement: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - "~>"
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '0.14'
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: 0.14.9
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0.14'
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: 0.14.9
|
73
|
+
- !ruby/object:Gem::Dependency
|
74
|
+
name: rest-client
|
75
|
+
requirement: !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- - ">="
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '0'
|
80
|
+
type: :runtime
|
81
|
+
prerelease: false
|
82
|
+
version_requirements: !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
84
|
+
- - ">="
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '0'
|
87
|
+
- !ruby/object:Gem::Dependency
|
88
|
+
name: rubyzip
|
89
|
+
requirement: !ruby/object:Gem::Requirement
|
90
|
+
requirements:
|
91
|
+
- - ">="
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
type: :runtime
|
95
|
+
prerelease: false
|
96
|
+
version_requirements: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '0'
|
101
|
+
description: |2
|
102
|
+
QAT Report Xray Standalone belongs to QAT Report collection but stand alone version, so no dependencies from other
|
103
|
+
QAT gems are required.
|
104
|
+
email: qatoolkit@readinessit.com
|
105
|
+
executables: []
|
106
|
+
extensions: []
|
107
|
+
extra_rdoc_files: []
|
108
|
+
files:
|
109
|
+
- LICENSE
|
110
|
+
- lib/qat/reporter/xray.rb
|
111
|
+
- lib/qat/reporter/xray/config.rb
|
112
|
+
- lib/qat/reporter/xray/issue.rb
|
113
|
+
- lib/qat/reporter/xray/publisher.rb
|
114
|
+
- lib/qat/reporter/xray/publisher/base.rb
|
115
|
+
- lib/qat/reporter/xray/publisher/cloud.rb
|
116
|
+
- lib/qat/reporter/xray/publisher/hosted.rb
|
117
|
+
- lib/qat/reporter/xray/tasks.rb
|
118
|
+
- lib/qat/reporter/xray/tasks/tests.rb
|
119
|
+
- lib/qat/reporter/xray/tasks/tests/helpers.rb
|
120
|
+
- lib/qat/reporter/xray/tasks/tests/report.rb
|
121
|
+
- lib/qat/reporter/xray/test.rb
|
122
|
+
- lib/qat/reporter/xray/test_execution.rb
|
123
|
+
- lib/qat/reporter/xray/version.rb
|
124
|
+
homepage: https://www.ritain.io
|
125
|
+
licenses:
|
126
|
+
- GPL-3.0
|
127
|
+
metadata:
|
128
|
+
source_code_uri: https://github.com/Ritain-io/qat-reporter-xray-standalone
|
129
|
+
post_install_message:
|
130
|
+
rdoc_options: []
|
131
|
+
require_paths:
|
132
|
+
- lib
|
133
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
134
|
+
requirements:
|
135
|
+
- - "~>"
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
version: '3.2'
|
138
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
139
|
+
requirements:
|
140
|
+
- - ">="
|
141
|
+
- !ruby/object:Gem::Version
|
142
|
+
version: '0'
|
143
|
+
requirements: []
|
144
|
+
rubygems_version: 3.3.26
|
145
|
+
signing_key:
|
146
|
+
specification_version: 4
|
147
|
+
summary: Utility for Test Reports in Jira Xray.
|
148
|
+
test_files: []
|