onlyoffice_testrail_wrapper 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/onlyoffice_testrail_wrapper.rb +10 -0
- data/lib/onlyoffice_testrail_wrapper/helpers/hash_helper.rb +21 -0
- data/lib/onlyoffice_testrail_wrapper/helpers/rspec_helper.rb +24 -0
- data/lib/onlyoffice_testrail_wrapper/helpers/ruby_helper.rb +10 -0
- data/lib/onlyoffice_testrail_wrapper/helpers/string_helper.rb +12 -0
- data/lib/onlyoffice_testrail_wrapper/helpers/system_helper.rb +17 -0
- data/lib/onlyoffice_testrail_wrapper/mock/rspec_example_mock.rb +40 -0
- data/lib/onlyoffice_testrail_wrapper/name.rb +9 -0
- data/lib/onlyoffice_testrail_wrapper/rspec_extension.rb +14 -0
- data/lib/onlyoffice_testrail_wrapper/testrail.rb +187 -0
- data/lib/onlyoffice_testrail_wrapper/testrail_case.rb +67 -0
- data/lib/onlyoffice_testrail_wrapper/testrail_helper.rb +173 -0
- data/lib/onlyoffice_testrail_wrapper/testrail_helper/testrail_helper_rspec_metadata.rb +55 -0
- data/lib/onlyoffice_testrail_wrapper/testrail_helper/testrail_status_helper.rb +18 -0
- data/lib/onlyoffice_testrail_wrapper/testrail_milestone.rb +23 -0
- data/lib/onlyoffice_testrail_wrapper/testrail_plan.rb +92 -0
- data/lib/onlyoffice_testrail_wrapper/testrail_plan_entry.rb +16 -0
- data/lib/onlyoffice_testrail_wrapper/testrail_project.rb +227 -0
- data/lib/onlyoffice_testrail_wrapper/testrail_project/testrail_project_plan_helper.rb +65 -0
- data/lib/onlyoffice_testrail_wrapper/testrail_result.rb +47 -0
- data/lib/onlyoffice_testrail_wrapper/testrail_run.rb +147 -0
- data/lib/onlyoffice_testrail_wrapper/testrail_section.rb +109 -0
- data/lib/onlyoffice_testrail_wrapper/testrail_suite.rb +113 -0
- data/lib/onlyoffice_testrail_wrapper/testrail_test.rb +40 -0
- data/lib/onlyoffice_testrail_wrapper/testrail_tools/testrail_tools.rb +119 -0
- data/lib/onlyoffice_testrail_wrapper/version.rb +7 -0
- metadata +237 -0
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module OnlyofficeTestrailWrapper
|
4
|
+
# @author Roman.Zagudaev
|
5
|
+
# Class for working with Test results
|
6
|
+
class TestrailResult
|
7
|
+
RESULT_STATUSES = { passed: 1, blocked: 2, untested: 3, retest: 4, failed: 5, passed_2: 6, work_for_me: 7,
|
8
|
+
pending: 8, aborted: 9, js_error: 10, lpv: 11, service_unavailable: 12 }.freeze
|
9
|
+
# @return [Integer] Id of test result
|
10
|
+
attr_accessor :id
|
11
|
+
# @return [String] Title of test result
|
12
|
+
attr_accessor :title
|
13
|
+
# @return [Integer] Status id of result
|
14
|
+
attr_accessor :status_id
|
15
|
+
# @return [String] Comment of result
|
16
|
+
attr_accessor :comment
|
17
|
+
# @return [String] Version
|
18
|
+
attr_accessor :version
|
19
|
+
# @return [Integer] date of creation of result from begging of era
|
20
|
+
attr_accessor :created_on
|
21
|
+
attr_reader :test_id
|
22
|
+
# @return [String] error if any happened
|
23
|
+
attr_accessor :error
|
24
|
+
|
25
|
+
# Default constructor
|
26
|
+
# @param [Symbol] status status to set. Could be :passed, blocked, retest or :failed
|
27
|
+
# @param [String] comment Comment of result
|
28
|
+
# @param [String] version Version
|
29
|
+
# @return [TestResultTestRail] new Test result
|
30
|
+
def initialize(status = nil, comment = nil, version = nil)
|
31
|
+
@title = status.to_s
|
32
|
+
@status_id = RESULT_STATUSES[status]
|
33
|
+
@comment = comment
|
34
|
+
@version = version
|
35
|
+
@error = nil
|
36
|
+
end
|
37
|
+
|
38
|
+
# Add result of test result
|
39
|
+
# @param [Integer] status id of status to set
|
40
|
+
# @param [String] comment comment of result
|
41
|
+
# @param [String] version version of test program
|
42
|
+
# @return nothing
|
43
|
+
# def add_result(status, comment, version)
|
44
|
+
# Testrail2.http_post(Testrail2.add_test_result(self.id), {:status_id => RESULT_STATUSES[status], :comment => comment, :version => version})
|
45
|
+
# end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,147 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'testrail_test'
|
4
|
+
|
5
|
+
module OnlyofficeTestrailWrapper
|
6
|
+
# @author Roman.Zagudaev
|
7
|
+
# Class for working with TestRun in TestRail
|
8
|
+
class TestrailRun
|
9
|
+
# @return [String] Name of test Run
|
10
|
+
attr_accessor :name
|
11
|
+
# @return [Integer] Id of test run
|
12
|
+
attr_accessor :id
|
13
|
+
# @return [Integer] Id of test suite
|
14
|
+
attr_accessor :suite_id
|
15
|
+
# @return [Integer] Id of project
|
16
|
+
attr_accessor :project_id
|
17
|
+
# @return [String] Description of test run
|
18
|
+
attr_accessor :description
|
19
|
+
# @return [Integer] Id of milestone
|
20
|
+
attr_accessor :milestone_id
|
21
|
+
# @return [Integer] Id of user to thom test assigned
|
22
|
+
attr_accessor :assignedto_id
|
23
|
+
# @return [Bool] parameter of including all test cases
|
24
|
+
attr_accessor :include_all_cases
|
25
|
+
# @return [Integer] Count of failed tests
|
26
|
+
attr_accessor :failed_count
|
27
|
+
# @return [Integer] Count of untested tests
|
28
|
+
attr_accessor :untested_count
|
29
|
+
# @return [Integer] Count of retest tests
|
30
|
+
attr_accessor :retest_count
|
31
|
+
# @return [Integer] Count of passed tests
|
32
|
+
attr_accessor :passed_count
|
33
|
+
# @return [Array] case Id's to include to run
|
34
|
+
# attr_accessor :case_ids
|
35
|
+
# @return [String] url to current test run
|
36
|
+
attr_reader :url
|
37
|
+
attr_accessor :tests_names
|
38
|
+
# @return [Array] array of arrays of TestResults
|
39
|
+
attr_accessor :test_results
|
40
|
+
|
41
|
+
# Default constructor
|
42
|
+
# @param [Integer] id id of test, default = nil
|
43
|
+
# @param [String] name name of test run, default = nil
|
44
|
+
# @param [String] description description of test run
|
45
|
+
# @return [TestRunTestRail] new Test run
|
46
|
+
def initialize(name = '', description = '', suite_id = nil, id = nil)
|
47
|
+
@id = id
|
48
|
+
@name = name
|
49
|
+
@description = description
|
50
|
+
@suite_id = suite_id
|
51
|
+
@tests_names = {}
|
52
|
+
@test_results = []
|
53
|
+
end
|
54
|
+
|
55
|
+
# Get all incomplete test (With status 'Untested' or 'Rerun')
|
56
|
+
# @return [Array, TestCaseTestrail] array of test cases
|
57
|
+
def get_incomplete_tests
|
58
|
+
incomplete_tests = []
|
59
|
+
get_tests.each do |test|
|
60
|
+
incomplete_tests << test if test.status_id == TestrailResult::RESULT_STATUSES[:retest] ||
|
61
|
+
test.status_id == TestrailResult::RESULT_STATUSES[:untested]
|
62
|
+
end
|
63
|
+
incomplete_tests
|
64
|
+
end
|
65
|
+
|
66
|
+
def close
|
67
|
+
test_run = HashHelper.parse_to_class_variable(Testrail2.http_post("index.php?/api/v2/close_run/#{@id}", {}), TestrailRun)
|
68
|
+
OnlyofficeLoggerHelper.log "Closed run: #{@name}"
|
69
|
+
test_run
|
70
|
+
end
|
71
|
+
|
72
|
+
def test(name_or_id)
|
73
|
+
case name_or_id.class.to_s
|
74
|
+
when 'Fixnum', 'Integer'
|
75
|
+
get_test_by_id name_or_id
|
76
|
+
when 'String'
|
77
|
+
get_test_by_name name_or_id
|
78
|
+
else
|
79
|
+
raise 'Wrong argument. Must be name [String] or id [Integer]'
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def get_test_by_id(id)
|
84
|
+
HashHelper.parse_to_class_variable(Testrail2.http_get("index.php?/api/v2/get_test/#{id}"), TestrailTest)
|
85
|
+
end
|
86
|
+
|
87
|
+
# Get all tests
|
88
|
+
# @return [Array, TestCaseTestrail] array of test cases
|
89
|
+
def get_tests
|
90
|
+
tests = Testrail2.http_get "index.php?/api/v2/get_tests/#{@id}"
|
91
|
+
@tests_names = HashHelper.get_hash_from_array_with_two_parameters(tests, 'title', 'id') if @tests_names.empty?
|
92
|
+
tests
|
93
|
+
end
|
94
|
+
|
95
|
+
def get_test_by_name(name)
|
96
|
+
get_tests if @tests_names.empty?
|
97
|
+
@tests_names[StringHelper.warnstrip!(name.to_s.dup)].nil? ? nil : get_test_by_id(@tests_names[name])
|
98
|
+
end
|
99
|
+
|
100
|
+
def add_result_by_case_id(result, case_id, comment = '', version = '')
|
101
|
+
HashHelper.parse_to_class_variable(Testrail2.http_post("index.php?/api/v2/add_result_for_case/#{@id}/#{case_id}",
|
102
|
+
status_id: TestrailResult[result], comment: comment, version: version), TestrailResult)
|
103
|
+
end
|
104
|
+
|
105
|
+
def parent_suite
|
106
|
+
@suite = TestrailTest.http_get "index.php?/api/v2/get_suite/#{@suite_id}"
|
107
|
+
end
|
108
|
+
|
109
|
+
def update(name = @name, description = @description)
|
110
|
+
@project.runs_names.delete @name
|
111
|
+
@project.runs_names[StringHelper.warnstrip!(name.to_s)] = @id
|
112
|
+
updated_plan = HashHelper.parse_to_class_variable(Testrail2.http_post("index.php?/api/v2/update_run/#{@id}", name: name, description: description), TestrailRun)
|
113
|
+
OnlyofficeLoggerHelper.log "Updated run: #{updated_plan.name}"
|
114
|
+
updated_plan
|
115
|
+
end
|
116
|
+
|
117
|
+
def delete
|
118
|
+
@project.runs_names.delete name
|
119
|
+
Testrail2.http_post "index.php?/api/v2/delete_run/#{@id}", {}
|
120
|
+
OnlyofficeLoggerHelper.log "Deleted run: #{@name}"
|
121
|
+
nil
|
122
|
+
end
|
123
|
+
|
124
|
+
def pull_tests_results
|
125
|
+
@test_results = {}
|
126
|
+
all_tests = get_tests
|
127
|
+
all_tests.each do |current_test|
|
128
|
+
test_data = test(current_test['id'])
|
129
|
+
@test_results.merge!(test_data.title => test_data.get_results)
|
130
|
+
end
|
131
|
+
OnlyofficeLoggerHelper.log "Get test results for run: #{@name}"
|
132
|
+
end
|
133
|
+
|
134
|
+
# Calculate duration of all tests in current spec in hours
|
135
|
+
# @return [Float] duration of tests in hours
|
136
|
+
def duration
|
137
|
+
pull_tests_results
|
138
|
+
test_results_date_array = []
|
139
|
+
@test_results.each_value do |test_result_sets|
|
140
|
+
test_result_sets.each do |test_result|
|
141
|
+
test_results_date_array << test_result.created_on
|
142
|
+
end
|
143
|
+
end
|
144
|
+
((test_results_date_array.max - test_results_date_array.min).to_f / (60 * 60)).round(2)
|
145
|
+
end
|
146
|
+
end
|
147
|
+
end
|
@@ -0,0 +1,109 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'testrail_case'
|
4
|
+
|
5
|
+
module OnlyofficeTestrailWrapper
|
6
|
+
# @author Roman.Zagudaev
|
7
|
+
# Class for description of test sections
|
8
|
+
class TestrailSection
|
9
|
+
# @return [Integer] Id of test section
|
10
|
+
attr_accessor :id
|
11
|
+
# @return [Integer] Id of parent test section
|
12
|
+
attr_accessor :parent_id
|
13
|
+
# @return [String] Name of test section
|
14
|
+
attr_accessor :name
|
15
|
+
# @return [Integer] Id of suite
|
16
|
+
attr_accessor :suite_id
|
17
|
+
# @return [Array, TestrailCase] cases inside section
|
18
|
+
attr_accessor :cases_names
|
19
|
+
|
20
|
+
# Default constructor
|
21
|
+
# @param [String] name name of test section, default = ""
|
22
|
+
# @param [Integer] id id of test section, default = nil
|
23
|
+
# @param [Integer] parent_id id of parent section, default = nil
|
24
|
+
# @param [Integer] suite_id id of test suite
|
25
|
+
# @return [TestSectionTestRail] new Test section
|
26
|
+
def initialize(name = '', parent_id = nil, suite_id = nil, id = nil)
|
27
|
+
@id = id
|
28
|
+
@name = name
|
29
|
+
@suite_id = suite_id
|
30
|
+
@parent_id = parent_id
|
31
|
+
end
|
32
|
+
|
33
|
+
def case(name_or_id)
|
34
|
+
case name_or_id.class.to_s
|
35
|
+
when 'Fixnum'
|
36
|
+
get_case_by_id name_or_id
|
37
|
+
when 'String'
|
38
|
+
if name_or_id.to_s.length > 250
|
39
|
+
OnlyofficeLoggerHelper.log("There is limit for testcase name for 250 symbols. '#{name_or_id}' too long. It will cut")
|
40
|
+
name_or_id = name_or_id.to_s[0..249]
|
41
|
+
end
|
42
|
+
init_case_by_name name_or_id
|
43
|
+
else
|
44
|
+
raise 'Wrong argument. Must be name [String] or id [Integer]'
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def get_case_by_id(id)
|
49
|
+
test_case = HashHelper.parse_to_class_variable(Testrail2.http_get("index.php?/api/v2/get_case/#{id}"), TestrailCase)
|
50
|
+
test_case.instance_variable_set '@section', self
|
51
|
+
test_case
|
52
|
+
end
|
53
|
+
|
54
|
+
# Get all cases of section
|
55
|
+
# @return [Array, TestCaseTestrail] array of test cases
|
56
|
+
def get_cases
|
57
|
+
# raise 'Project id is not identified' if @project_id.nil?
|
58
|
+
cases = Testrail2.http_get("index.php?/api/v2/get_cases/#{@project_id}&suite_id=#{@suite_id}§ion_id=#{@id}")
|
59
|
+
@cases_names = HashHelper.get_hash_from_array_with_two_parameters(cases, 'title', 'id') if @cases_names.nil?
|
60
|
+
cases
|
61
|
+
end
|
62
|
+
|
63
|
+
def get_case_by_name(name)
|
64
|
+
get_cases if @cases_names.nil?
|
65
|
+
corrected_case_name = StringHelper.warnstrip!(name.to_s)
|
66
|
+
return nil if @cases_names[corrected_case_name].nil?
|
67
|
+
|
68
|
+
get_case_by_id(@cases_names[corrected_case_name])
|
69
|
+
end
|
70
|
+
|
71
|
+
# Init case by it's name
|
72
|
+
# @param [String] name name of test case
|
73
|
+
# @return [TestrailCase] test case with this name
|
74
|
+
def init_case_by_name(name)
|
75
|
+
test_case = get_case_by_name name
|
76
|
+
test_case.nil? ? create_new_case(name) : test_case
|
77
|
+
end
|
78
|
+
|
79
|
+
# Add test case to current Section
|
80
|
+
# @param [String] title name of test case to add
|
81
|
+
# @param [Integer] type_id type of test case to add (Default = 3)
|
82
|
+
# @param [Integer] priority_id id of priority of case (Default = 4)
|
83
|
+
# @param [String] custom_steps steps to perform
|
84
|
+
# @return [TestCaseTestrail] created test case
|
85
|
+
def create_new_case(title, type_id = 3, priority_id = 4, custom_steps = '')
|
86
|
+
new_case = HashHelper.parse_to_class_variable(Testrail2.http_post("index.php?/api/v2/add_case/#{@id}", title: StringHelper.warnstrip!(title.to_s), type_id: type_id,
|
87
|
+
priority_id: priority_id, custom_steps: custom_steps), TestrailCase)
|
88
|
+
new_case.instance_variable_set('@section', self)
|
89
|
+
OnlyofficeLoggerHelper.log "Created new case: #{new_case.title}"
|
90
|
+
@cases_names[new_case.title] = new_case.id
|
91
|
+
new_case
|
92
|
+
end
|
93
|
+
|
94
|
+
def update(name = @name, parent_id = @parent_id)
|
95
|
+
@suite.sections_names.delete @name
|
96
|
+
@suite.sections_names[StringHelper.warnstrip!(name.to_s)] = @id
|
97
|
+
updated_section = HashHelper.parse_to_class_variable(Testrail2.http_post("index.php?/api/v2/update_section/#{@id}", name: name, parent_id: parent_id), TestrailSection)
|
98
|
+
OnlyofficeLoggerHelper.log "Updated section: #{updated_section.name}"
|
99
|
+
updated_section
|
100
|
+
end
|
101
|
+
|
102
|
+
def delete
|
103
|
+
@suite.sections_names.delete @name
|
104
|
+
Testrail2.http_post "index.php?/api/v2/delete_section/#{@id}", {}
|
105
|
+
OnlyofficeLoggerHelper.log "Deleted section: #{@name}"
|
106
|
+
nil
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
@@ -0,0 +1,113 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'testrail_project'
|
4
|
+
require_relative 'testrail_section'
|
5
|
+
require_relative 'testrail_run'
|
6
|
+
|
7
|
+
module OnlyofficeTestrailWrapper
|
8
|
+
# @author Roman.Zagudaev
|
9
|
+
# Class for description of test suites
|
10
|
+
class TestrailSuite
|
11
|
+
# @return [Integer] Id of test suite
|
12
|
+
attr_accessor :id
|
13
|
+
# @return [String] Name of test suite
|
14
|
+
attr_accessor :name
|
15
|
+
# @return [String] description of test suite
|
16
|
+
attr_accessor :description
|
17
|
+
# @return [true, false] id of project of test suite
|
18
|
+
attr_accessor :project_id
|
19
|
+
# @return [Array] sections in suite
|
20
|
+
attr_accessor :sections_names
|
21
|
+
# @return [String] url to current suite
|
22
|
+
attr_reader :url
|
23
|
+
|
24
|
+
# Default constructor
|
25
|
+
# @param [Integer] id id of test suite, default = nil
|
26
|
+
# @param [String] name name of test suite, default = nil
|
27
|
+
# @param [String] description description of test suite, default = nil
|
28
|
+
# @param [Integer] project_id id of project of test suite
|
29
|
+
# @return [TestrailSuite] new Test suite
|
30
|
+
def initialize(name = nil, description = nil, project_id = nil, id = nil)
|
31
|
+
@id = id
|
32
|
+
@name = name
|
33
|
+
@description = description
|
34
|
+
@project_id = project_id
|
35
|
+
end
|
36
|
+
|
37
|
+
# Start test run from test suite
|
38
|
+
# @param [String] name name of started test run
|
39
|
+
# @param [String] description description of test run
|
40
|
+
# @return [TestRunTestRail] created test run
|
41
|
+
def start_test_run(name, description = '')
|
42
|
+
HashHelper.parse_to_class_variable(Testrail2.http_post("index.php?/api/v2/add_run/#{@project_id}", name: StringHelper.warnstrip!(name.to_s), description: description, suite_id: @id), TestrailRun)
|
43
|
+
end
|
44
|
+
|
45
|
+
def section(name_or_id = 'All Test Cases')
|
46
|
+
case name_or_id.class.to_s
|
47
|
+
when 'Fixnum'
|
48
|
+
get_section_by_id name_or_id
|
49
|
+
when 'String'
|
50
|
+
init_section_by_name name_or_id
|
51
|
+
else
|
52
|
+
raise 'Wrong argument. Must be name [String] or id [Integer]'
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
# Create new section of test suite
|
57
|
+
# @param [String] name of test section to create
|
58
|
+
# @param [Integer] parent_section id of parent section, default = nil
|
59
|
+
def create_new_section(name, parent_section = nil)
|
60
|
+
parent_section = get_section_by_name(parent_section).id if parent_section.is_a?(String)
|
61
|
+
new_section = HashHelper.parse_to_class_variable(Testrail2.http_post("index.php?/api/v2/add_section/#{@project_id}", name: StringHelper.warnstrip!(name.to_s),
|
62
|
+
parent_id: parent_section, suite_id: @id), TestrailSection)
|
63
|
+
OnlyofficeLoggerHelper.log "Created new section: #{new_section.name}"
|
64
|
+
@sections_names[new_section.name] = new_section.id
|
65
|
+
new_section.instance_variable_set '@project_id', @project_id
|
66
|
+
new_section.instance_variable_set '@suite', self
|
67
|
+
new_section
|
68
|
+
end
|
69
|
+
|
70
|
+
# Get all sections in test suite
|
71
|
+
# @return [Array, TestrailSuite] array with sections
|
72
|
+
def get_sections
|
73
|
+
sections = Testrail2.http_get("index.php?/api/v2/get_sections/#{@project_id}&suite_id=#{@id}")
|
74
|
+
@sections_names = HashHelper.get_hash_from_array_with_two_parameters(sections, 'name', 'id') if @sections_names.nil?
|
75
|
+
sections
|
76
|
+
end
|
77
|
+
|
78
|
+
def get_section_by_id(id)
|
79
|
+
section = HashHelper.parse_to_class_variable(Testrail2.http_get("index.php?/api/v2/get_section/#{id}"), TestrailSection)
|
80
|
+
section.instance_variable_set '@project_id', @project_id
|
81
|
+
section.instance_variable_set '@suite', self
|
82
|
+
section
|
83
|
+
end
|
84
|
+
|
85
|
+
def get_section_by_name(name)
|
86
|
+
get_sections if @sections_names.nil?
|
87
|
+
@sections_names[StringHelper.warnstrip!(name.to_s)].nil? ? nil : get_section_by_id(@sections_names[name])
|
88
|
+
end
|
89
|
+
|
90
|
+
# Init section by it's name
|
91
|
+
# @param [String] name name of section
|
92
|
+
# @return [TestrailSection] Section with this name
|
93
|
+
def init_section_by_name(name, parent_section = nil)
|
94
|
+
found_section = get_section_by_name name
|
95
|
+
found_section.nil? ? create_new_section(name, parent_section) : found_section
|
96
|
+
end
|
97
|
+
|
98
|
+
def delete
|
99
|
+
Testrail2.http_post "index.php?/api/v2/delete_suite/#{@id}", {}
|
100
|
+
OnlyofficeLoggerHelper.log "Deleted suite: #{@name}"
|
101
|
+
@project.suites_names.delete @name
|
102
|
+
nil
|
103
|
+
end
|
104
|
+
|
105
|
+
def update(name, description = nil)
|
106
|
+
@project.suites_names.delete @name
|
107
|
+
@project.suites_names[StringHelper.warnstrip!(name.to_s)] = @id
|
108
|
+
updated_suite = HashHelper.parse_to_class_variable(Testrail2.http_post("index.php?/api/v2/update_suite/#{@id}", name: name, description: description), TestrailSuite)
|
109
|
+
OnlyofficeLoggerHelper.log "Updated suite: #{updated_suite.name}"
|
110
|
+
updated_suite
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'testrail_result'
|
4
|
+
|
5
|
+
module OnlyofficeTestrailWrapper
|
6
|
+
class TestrailTest
|
7
|
+
# @return [Integer] test id
|
8
|
+
attr_accessor :id
|
9
|
+
# @return [Integer] test run id
|
10
|
+
attr_accessor :run_id
|
11
|
+
# @return [Integer] status id
|
12
|
+
attr_accessor :status_id
|
13
|
+
# @return [Integer] case id
|
14
|
+
attr_accessor :case_id
|
15
|
+
# @return [String] test title
|
16
|
+
attr_accessor :title
|
17
|
+
# @return [Integer] assigned to id
|
18
|
+
attr_accessor :assignedto_id
|
19
|
+
|
20
|
+
def initialize(id = nil, run_id = nil, case_id = nil, title = '')
|
21
|
+
@id = id
|
22
|
+
@title = title
|
23
|
+
@case_id = case_id
|
24
|
+
@run_id = run_id
|
25
|
+
end
|
26
|
+
|
27
|
+
def get_results
|
28
|
+
@results.nil? ? @results = Testrail2.http_get("index.php?/api/v2/get_results/#{@id}") : (return @results)
|
29
|
+
@results.each_with_index { |result, index| @results[index] = HashHelper.parse_to_class_variable(result, TestrailResult) }
|
30
|
+
@results
|
31
|
+
end
|
32
|
+
|
33
|
+
def add_result(result, comment = '', version = '')
|
34
|
+
result = TestrailResult::RESULT_STATUSES[result] if result.is_a?(Symbol)
|
35
|
+
HashHelper.parse_to_class_variable(Testrail2.http_post("index.php?/api/v2/add_result/#{@id}", status_id: result,
|
36
|
+
comment: comment, version: version), TestrailResult)
|
37
|
+
OnlyofficeLoggerHelper.log "Set test result: #{result}"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|