onlyoffice_testrail_wrapper 0.2.0 → 0.4.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 +4 -4
- data/lib/onlyoffice_testrail_wrapper/helpers/rspec_helper.rb +2 -0
- data/lib/onlyoffice_testrail_wrapper/helpers/ruby_helper.rb +2 -0
- data/lib/onlyoffice_testrail_wrapper/helpers/string_helper.rb +4 -0
- data/lib/onlyoffice_testrail_wrapper/mock/rspec_example_mock.rb +8 -3
- data/lib/onlyoffice_testrail_wrapper/testrail/requests_helper.rb +52 -0
- data/lib/onlyoffice_testrail_wrapper/testrail.rb +29 -70
- data/lib/onlyoffice_testrail_wrapper/testrail_api_object.rb +26 -0
- data/lib/onlyoffice_testrail_wrapper/testrail_case.rb +12 -6
- data/lib/onlyoffice_testrail_wrapper/testrail_helper/example_failed_got_expected_exception.rb +26 -0
- data/lib/onlyoffice_testrail_wrapper/testrail_helper/example_lpv_exception.rb +20 -0
- data/lib/onlyoffice_testrail_wrapper/testrail_helper/example_service_unavailable_exception.rb +20 -0
- data/lib/onlyoffice_testrail_wrapper/testrail_helper.rb +28 -51
- data/lib/onlyoffice_testrail_wrapper/testrail_milestone.rb +22 -4
- data/lib/onlyoffice_testrail_wrapper/testrail_plan.rb +12 -4
- data/lib/onlyoffice_testrail_wrapper/testrail_plan_entry.rb +3 -1
- data/lib/onlyoffice_testrail_wrapper/testrail_project/testrail_project_milestone_methods.rb +23 -4
- data/lib/onlyoffice_testrail_wrapper/testrail_project/testrail_project_plan_helper.rb +16 -11
- data/lib/onlyoffice_testrail_wrapper/testrail_project/testrail_project_runs_methods.rb +9 -6
- data/lib/onlyoffice_testrail_wrapper/testrail_project/testrail_project_suite_methods.rb +9 -7
- data/lib/onlyoffice_testrail_wrapper/testrail_project.rb +7 -6
- data/lib/onlyoffice_testrail_wrapper/testrail_result.rb +2 -1
- data/lib/onlyoffice_testrail_wrapper/testrail_run.rb +12 -7
- data/lib/onlyoffice_testrail_wrapper/testrail_section.rb +14 -8
- data/lib/onlyoffice_testrail_wrapper/testrail_suite.rb +19 -11
- data/lib/onlyoffice_testrail_wrapper/testrail_test.rb +19 -7
- data/lib/onlyoffice_testrail_wrapper/testrail_tools/testrail_tools.rb +4 -2
- data/lib/onlyoffice_testrail_wrapper/version.rb +1 -1
- data/lib/onlyoffice_testrail_wrapper.rb +1 -1
- metadata +17 -131
- data/lib/onlyoffice_testrail_wrapper/helpers/hash_helper.rb +0 -21
- data/lib/onlyoffice_testrail_wrapper/testrail_helper/testrail_status_helper.rb +0 -18
@@ -3,7 +3,8 @@
|
|
3
3
|
require_relative 'testrail_plan_entry'
|
4
4
|
|
5
5
|
module OnlyofficeTestrailWrapper
|
6
|
-
|
6
|
+
# Class for working with testrail plan
|
7
|
+
class TestrailPlan < TestrailApiObject
|
7
8
|
# @return [Integer] Id of test plan
|
8
9
|
attr_accessor :id
|
9
10
|
# @return [String] test run name
|
@@ -22,8 +23,11 @@ module OnlyofficeTestrailWrapper
|
|
22
23
|
attr_reader :created_on
|
23
24
|
# @return [String] url to current test plan
|
24
25
|
attr_reader :url
|
26
|
+
# @return [String] error message if any happens
|
27
|
+
attr_reader :error
|
25
28
|
|
26
29
|
def initialize(name = '', entries = [], description = '', milestone_id = nil, id = nil)
|
30
|
+
super()
|
27
31
|
@name = name
|
28
32
|
@entries = entries
|
29
33
|
@description = description
|
@@ -32,10 +36,14 @@ module OnlyofficeTestrailWrapper
|
|
32
36
|
end
|
33
37
|
|
34
38
|
def add_entry(name, suite_id, include_all = true, case_ids = [], assigned_to = nil)
|
35
|
-
entry =
|
36
|
-
|
39
|
+
entry = TestrailPlanEntry.new.init_from_hash(Testrail2.http_post("index.php?/api/v2/add_plan_entry/#{@id}",
|
40
|
+
suite_id: suite_id,
|
41
|
+
name: StringHelper.warnstrip!(name.to_s),
|
42
|
+
include_all: include_all,
|
43
|
+
case_ids: case_ids,
|
44
|
+
assigned_to: assigned_to))
|
37
45
|
OnlyofficeLoggerHelper.log "Added plan entry: #{name.to_s.strip}"
|
38
|
-
entry.runs.each_with_index { |run, index| entry.runs[index] =
|
46
|
+
entry.runs.each_with_index { |run, index| entry.runs[index] = TestrailRun.new.init_from_hash(run) }
|
39
47
|
entry
|
40
48
|
end
|
41
49
|
|
@@ -1,10 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module OnlyofficeTestrailWrapper
|
4
|
-
|
4
|
+
# Class for working with testrail plan entry
|
5
|
+
class TestrailPlanEntry < TestrailApiObject
|
5
6
|
attr_accessor :suite_id, :name, :assigned_to, :include_all, :case_ids, :runs
|
6
7
|
|
7
8
|
def initialize(params = {})
|
9
|
+
super()
|
8
10
|
@suite_id = params.fetch(:suite_id, nil)
|
9
11
|
@name = params.fetch(:name, '')
|
10
12
|
@include_all = params.fetch(:include_all, true)
|
@@ -3,9 +3,12 @@
|
|
3
3
|
module OnlyofficeTestrailWrapper
|
4
4
|
# Methods to perform operations on milestones
|
5
5
|
module TestrailProjectMilestoneMethods
|
6
|
+
# Get milestone data by parameter
|
7
|
+
# @param [String, Integer] name_or_id id or name of milestone
|
8
|
+
# @return [TestrailMilestone]
|
6
9
|
def milestone(name_or_id)
|
7
10
|
case name_or_id.class.to_s
|
8
|
-
when 'Fixnum'
|
11
|
+
when 'Fixnum', 'Integer'
|
9
12
|
get_milestone_by_id name_or_id
|
10
13
|
when 'String'
|
11
14
|
init_milestone_by_name name_or_id
|
@@ -14,32 +17,48 @@ module OnlyofficeTestrailWrapper
|
|
14
17
|
end
|
15
18
|
end
|
16
19
|
|
20
|
+
# Get milestone data by it's name
|
21
|
+
# Will create a new one if no one found
|
22
|
+
# @param [String] name of milestone
|
23
|
+
# @return [TestrailMilestone]
|
17
24
|
def init_milestone_by_name(name)
|
18
25
|
found_milestone = get_milestone_by_name name
|
19
26
|
found_milestone.nil? ? create_new_milestone(name) : found_milestone
|
20
27
|
end
|
21
28
|
|
29
|
+
# Get milestone by it's id
|
30
|
+
# @param [Integer] id of milestone
|
31
|
+
# @return [TestrailMilestone]
|
22
32
|
def get_milestone_by_id(id)
|
23
|
-
milestone =
|
33
|
+
milestone = TestrailMilestone.new.init_from_hash(Testrail2.http_get("index.php?/api/v2/get_milestone/#{id}"))
|
24
34
|
OnlyofficeLoggerHelper.log("Initialized milestone: #{milestone.name}")
|
25
35
|
milestone
|
26
36
|
end
|
27
37
|
|
38
|
+
# Get milestone data by it's name
|
39
|
+
# @param [String] name of milestone
|
40
|
+
# @return [TestrailMilestone, nil] result or nil if not found
|
28
41
|
def get_milestone_by_name(name)
|
29
42
|
get_milestones if @milestones_names.empty?
|
30
43
|
@milestones_names[StringHelper.warnstrip!(name.to_s)].nil? ? nil : get_milestone_by_id(@milestones_names[name])
|
31
44
|
end
|
32
45
|
|
46
|
+
# Get list of all milestones
|
47
|
+
# @return [Array<TestrailMilestone>] list of all milestones
|
33
48
|
def get_milestones
|
34
49
|
milestones = Testrail2.http_get("index.php?/api/v2/get_milestones/#{@id}")
|
35
|
-
@milestones_names =
|
50
|
+
@milestones_names = name_id_pairs(milestones) if @milestones_names.empty?
|
36
51
|
milestones
|
37
52
|
end
|
38
53
|
|
54
|
+
# Create new milestone
|
39
55
|
# @param [String] name of milestone
|
40
56
|
# @param [String] description of milestone
|
57
|
+
# @return [TestrailMilestone]
|
41
58
|
def create_new_milestone(name, description = '')
|
42
|
-
new_milestone =
|
59
|
+
new_milestone = TestrailMilestone.new.init_from_hash(Testrail2.http_post("index.php?/api/v2/add_milestone/#{@id}",
|
60
|
+
:name => StringHelper.warnstrip!(name.to_s),
|
61
|
+
description => description))
|
43
62
|
OnlyofficeLoggerHelper.log "Created new milestone: #{new_milestone.name}"
|
44
63
|
new_milestone
|
45
64
|
end
|
@@ -5,7 +5,7 @@ module OnlyofficeTestrailWrapper
|
|
5
5
|
module TestrailProjectPlanHelper
|
6
6
|
def plan(name_or_id)
|
7
7
|
case name_or_id.class.to_s
|
8
|
-
when 'Fixnum'
|
8
|
+
when 'Fixnum', 'Integer'
|
9
9
|
get_plan_by_id name_or_id
|
10
10
|
when 'String'
|
11
11
|
init_plan_by_name name_or_id
|
@@ -20,14 +20,16 @@ module OnlyofficeTestrailWrapper
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def get_plan_by_id(id)
|
23
|
-
plan =
|
23
|
+
plan = TestrailPlan.new.init_from_hash(Testrail2.http_get("index.php?/api/v2/get_plan/#{id}"))
|
24
24
|
OnlyofficeLoggerHelper.log("Initialized plan: #{plan.name}")
|
25
|
+
raise("`get_plan_by_id(#{id})` return an error: `#{plan.error}`") if plan.error
|
26
|
+
|
25
27
|
plan.entries.each_with_index do |test_entry, index|
|
26
|
-
entry =
|
27
|
-
entry.runs.each_with_index { |run, i| entry.runs[i] =
|
28
|
+
entry = TestrailPlanEntry.new.init_from_hash(test_entry)
|
29
|
+
entry.runs.each_with_index { |run, i| entry.runs[i] = TestrailRun.new.init_from_hash(run) }
|
28
30
|
plan.entries[index] = entry
|
29
31
|
end
|
30
|
-
plan.instance_variable_set
|
32
|
+
plan.instance_variable_set :@project, self
|
31
33
|
plan
|
32
34
|
end
|
33
35
|
|
@@ -52,7 +54,7 @@ module OnlyofficeTestrailWrapper
|
|
52
54
|
get_url = "index.php?/api/v2/get_plans/#{@id}"
|
53
55
|
filters.each { |key, value| get_url += "&#{key}=#{value}" }
|
54
56
|
plans = Testrail2.http_get(get_url)
|
55
|
-
@plans_names =
|
57
|
+
@plans_names = name_id_pairs(plans) if @plans_names.empty?
|
56
58
|
plans
|
57
59
|
end
|
58
60
|
|
@@ -66,19 +68,22 @@ module OnlyofficeTestrailWrapper
|
|
66
68
|
get_url = "index.php?/api/v2/get_plans/#{@id}"
|
67
69
|
filters.each { |key, value| get_url += "&#{key}=#{value}" }
|
68
70
|
plans = Testrail2.http_get(get_url)
|
69
|
-
plans.map { |suite|
|
71
|
+
plans.map { |suite| TestrailPlan.new.init_from_hash(suite) }
|
70
72
|
end
|
71
73
|
|
72
74
|
# @param [String] name of test plan
|
73
75
|
# @param [String] description
|
74
76
|
# @param [Integer] milestone_id
|
75
77
|
def create_new_plan(name, entries = [], description = '', milestone_id = nil)
|
76
|
-
new_plan =
|
77
|
-
|
78
|
+
new_plan = TestrailPlan.new.init_from_hash(Testrail2.http_post("index.php?/api/v2/add_plan/#{@id}",
|
79
|
+
name: StringHelper.warnstrip!(name),
|
80
|
+
description: description,
|
81
|
+
milestone_id: milestone_id,
|
82
|
+
entries: entries))
|
78
83
|
OnlyofficeLoggerHelper.log "Created new plan: #{new_plan.name}"
|
79
84
|
new_plan.entries.each_with_index do |entry, i|
|
80
|
-
new_plan.entries[i] =
|
81
|
-
new_plan.entries[i].runs.each_with_index { |run, j| new_plan.entries[i].runs[j] =
|
85
|
+
new_plan.entries[i] = TestrailPlanEntry.new.init_from_hash(entry)
|
86
|
+
new_plan.entries[i].runs.each_with_index { |run, j| new_plan.entries[i].runs[j] = TestrailRun.new.init_from_hash(run) }
|
82
87
|
end
|
83
88
|
@plans_names[new_plan.name] = new_plan.id
|
84
89
|
new_plan
|
@@ -20,7 +20,7 @@ module OnlyofficeTestrailWrapper
|
|
20
20
|
get_url = "index.php?/api/v2/get_runs/#{@id}"
|
21
21
|
filters.each { |key, value| get_url += "&#{key}=#{value}" }
|
22
22
|
runs = Testrail2.http_get(get_url)
|
23
|
-
@runs_names =
|
23
|
+
@runs_names = name_id_pairs(runs) if @runs_names.empty?
|
24
24
|
runs
|
25
25
|
end
|
26
26
|
|
@@ -31,7 +31,7 @@ module OnlyofficeTestrailWrapper
|
|
31
31
|
get_url = "index.php?/api/v2/get_runs/#{@id}"
|
32
32
|
filters.each { |key, value| get_url += "&#{key}=#{value}" }
|
33
33
|
runs = Testrail2.http_get(get_url)
|
34
|
-
runs.map { |suite|
|
34
|
+
runs.map { |suite| TestrailRun.new.init_from_hash(suite) }
|
35
35
|
end
|
36
36
|
|
37
37
|
extend Gem::Deprecate
|
@@ -46,9 +46,9 @@ module OnlyofficeTestrailWrapper
|
|
46
46
|
end
|
47
47
|
|
48
48
|
def get_run_by_id(id)
|
49
|
-
run =
|
49
|
+
run = TestrailRun.new.init_from_hash(Testrail2.http_get("index.php?/api/v2/get_run/#{id}"))
|
50
50
|
OnlyofficeLoggerHelper.log("Initialized run: #{run.name}")
|
51
|
-
run.instance_variable_set(
|
51
|
+
run.instance_variable_set(:@project, self)
|
52
52
|
run
|
53
53
|
end
|
54
54
|
|
@@ -59,9 +59,12 @@ module OnlyofficeTestrailWrapper
|
|
59
59
|
end
|
60
60
|
|
61
61
|
def create_new_run(name, suite_id, description = '')
|
62
|
-
new_run =
|
62
|
+
new_run = TestrailRun.new.init_from_hash(Testrail2.http_post("index.php?/api/v2/add_run/#{@id}",
|
63
|
+
name: StringHelper.warnstrip!(name),
|
64
|
+
description: description,
|
65
|
+
suite_id: suite_id))
|
63
66
|
OnlyofficeLoggerHelper.log "Created new run: #{new_run.name}"
|
64
|
-
new_run.instance_variable_set(
|
67
|
+
new_run.instance_variable_set(:@project, self)
|
65
68
|
@runs_names[new_run.name] = new_run.id
|
66
69
|
new_run
|
67
70
|
end
|
@@ -5,7 +5,7 @@ module OnlyofficeTestrailWrapper
|
|
5
5
|
module TestrailProjectSuiteMethods
|
6
6
|
def suite(name_or_id)
|
7
7
|
case name_or_id.class.to_s
|
8
|
-
when 'Fixnum'
|
8
|
+
when 'Fixnum', 'Integer'
|
9
9
|
get_suite_by_id name_or_id
|
10
10
|
when 'String'
|
11
11
|
init_suite_by_name name_or_id
|
@@ -18,7 +18,7 @@ module OnlyofficeTestrailWrapper
|
|
18
18
|
# @return [Array<Hash>] array with suites data in hash
|
19
19
|
def get_suites
|
20
20
|
suites = Testrail2.http_get("index.php?/api/v2/get_suites/#{@id}")
|
21
|
-
@suites_names =
|
21
|
+
@suites_names = name_id_pairs(suites) if @suites_names.empty?
|
22
22
|
suites
|
23
23
|
end
|
24
24
|
|
@@ -29,7 +29,7 @@ module OnlyofficeTestrailWrapper
|
|
29
29
|
# @return [Array<TestrailSuite>] array with TestRailSuite
|
30
30
|
def suites
|
31
31
|
suites = Testrail2.http_get("index.php?/api/v2/get_suites/#{@id}")
|
32
|
-
suites.map { |suite|
|
32
|
+
suites.map { |suite| TestrailSuite.new.init_from_hash(suite) }
|
33
33
|
end
|
34
34
|
|
35
35
|
# Get Test Suite by it's name
|
@@ -41,8 +41,8 @@ module OnlyofficeTestrailWrapper
|
|
41
41
|
end
|
42
42
|
|
43
43
|
def get_suite_by_id(id)
|
44
|
-
suite =
|
45
|
-
suite.instance_variable_set(
|
44
|
+
suite = TestrailSuite.new.init_from_hash(Testrail2.http_get("index.php?/api/v2/get_suite/#{id}"))
|
45
|
+
suite.instance_variable_set(:@project, self)
|
46
46
|
OnlyofficeLoggerHelper.log("Initialized suite: #{suite.name}")
|
47
47
|
suite
|
48
48
|
end
|
@@ -60,8 +60,10 @@ module OnlyofficeTestrailWrapper
|
|
60
60
|
# @param [String] description description of suite
|
61
61
|
# @return [TestrailSuite] created suite
|
62
62
|
def create_new_suite(name, description = '')
|
63
|
-
new_suite =
|
64
|
-
|
63
|
+
new_suite = TestrailSuite.new.init_from_hash(Testrail2.http_post("index.php?/api/v2/add_suite/#{@id}",
|
64
|
+
name: StringHelper.warnstrip!(name),
|
65
|
+
description: description))
|
66
|
+
new_suite.instance_variable_set(:@project, self)
|
65
67
|
OnlyofficeLoggerHelper.log "Created new suite: #{new_suite.name}"
|
66
68
|
@suites_names[new_suite.name] = new_suite.id
|
67
69
|
new_suite
|
@@ -13,7 +13,7 @@ require_relative 'testrail_project/testrail_project_suite_methods'
|
|
13
13
|
module OnlyofficeTestrailWrapper
|
14
14
|
# @author Roman.Zagudaev
|
15
15
|
# Class for working with Test Projects
|
16
|
-
class TestrailProject
|
16
|
+
class TestrailProject < TestrailApiObject
|
17
17
|
include ProjectCleanup
|
18
18
|
include TestrailProjectMilestoneMethods
|
19
19
|
include TestrailProjectPlanHelper
|
@@ -49,6 +49,7 @@ module OnlyofficeTestrailWrapper
|
|
49
49
|
# @param is_completed [true, false] is project completed, default = nil
|
50
50
|
# @return [TestRunTestRail] new Test run
|
51
51
|
def initialize(name = '', announcement = nil, show_announcement = true, is_completed = false, id = nil)
|
52
|
+
super()
|
52
53
|
@id = id.to_i
|
53
54
|
@name = name
|
54
55
|
@announcement = announcement
|
@@ -61,10 +62,11 @@ module OnlyofficeTestrailWrapper
|
|
61
62
|
end
|
62
63
|
|
63
64
|
def update(is_completed = false, name = @name, announcement = @announcement, show_announcement = @show_announcement)
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
65
|
+
updated_project = TestrailProject.new.init_from_hash(Testrail2.http_post("index.php?/api/v2/update_project/#{@id}",
|
66
|
+
name: name,
|
67
|
+
announcement: announcement,
|
68
|
+
show_announcement: show_announcement,
|
69
|
+
is_completed: is_completed))
|
68
70
|
OnlyofficeLoggerHelper.log "Updated project: #{updated_project.name}"
|
69
71
|
updated_project
|
70
72
|
end
|
@@ -72,7 +74,6 @@ module OnlyofficeTestrailWrapper
|
|
72
74
|
def delete
|
73
75
|
Testrail2.http_post "index.php?/api/v2/delete_project/#{@id}", {}
|
74
76
|
OnlyofficeLoggerHelper.log "Deleted project: #{@name}"
|
75
|
-
@testrail.projects_names.delete @name
|
76
77
|
end
|
77
78
|
end
|
78
79
|
end
|
@@ -3,7 +3,7 @@
|
|
3
3
|
module OnlyofficeTestrailWrapper
|
4
4
|
# @author Roman.Zagudaev
|
5
5
|
# Class for working with Test results
|
6
|
-
class TestrailResult
|
6
|
+
class TestrailResult < TestrailApiObject
|
7
7
|
RESULT_STATUSES = { passed: 1, blocked: 2, untested: 3, retest: 4, failed: 5, passed_2: 6, work_for_me: 7,
|
8
8
|
pending: 8, aborted: 9, js_error: 10, lpv: 11, service_unavailable: 12 }.freeze
|
9
9
|
# @return [Integer] Id of test result
|
@@ -28,6 +28,7 @@ module OnlyofficeTestrailWrapper
|
|
28
28
|
# @param [String] version Version
|
29
29
|
# @return [TestResultTestRail] new Test result
|
30
30
|
def initialize(status = nil, comment = nil, version = nil)
|
31
|
+
super()
|
31
32
|
@title = status.to_s
|
32
33
|
@status_id = RESULT_STATUSES[status]
|
33
34
|
@comment = comment
|
@@ -5,7 +5,7 @@ require_relative 'testrail_test'
|
|
5
5
|
module OnlyofficeTestrailWrapper
|
6
6
|
# @author Roman.Zagudaev
|
7
7
|
# Class for working with TestRun in TestRail
|
8
|
-
class TestrailRun
|
8
|
+
class TestrailRun < TestrailApiObject
|
9
9
|
# @return [String] Name of test Run
|
10
10
|
attr_accessor :name
|
11
11
|
# @return [Integer] Id of test run
|
@@ -49,6 +49,7 @@ module OnlyofficeTestrailWrapper
|
|
49
49
|
# @param [Hash] params all other params
|
50
50
|
# @return [TestRunTestRail] new Test run
|
51
51
|
def initialize(name = '', description = '', suite_id = nil, id = nil, params = {})
|
52
|
+
super()
|
52
53
|
@id = id
|
53
54
|
@name = name
|
54
55
|
@description = description
|
@@ -71,7 +72,7 @@ module OnlyofficeTestrailWrapper
|
|
71
72
|
|
72
73
|
def close
|
73
74
|
OnlyofficeLoggerHelper.log("Starting to send command to close run: #{@name}")
|
74
|
-
test_run =
|
75
|
+
test_run = TestrailRun.new.init_from_hash(Testrail2.http_post("index.php?/api/v2/close_run/#{@id}", {}))
|
75
76
|
OnlyofficeLoggerHelper.log("Run is closed: #{@name}")
|
76
77
|
test_run
|
77
78
|
end
|
@@ -88,14 +89,14 @@ module OnlyofficeTestrailWrapper
|
|
88
89
|
end
|
89
90
|
|
90
91
|
def get_test_by_id(id)
|
91
|
-
|
92
|
+
TestrailTest.new.init_from_hash(Testrail2.http_get("index.php?/api/v2/get_test/#{id}"))
|
92
93
|
end
|
93
94
|
|
94
95
|
# Get all tests
|
95
96
|
# @return [Array, TestCaseTestrail] array of test cases
|
96
97
|
def get_tests
|
97
98
|
tests = Testrail2.http_get "index.php?/api/v2/get_tests/#{@id}"
|
98
|
-
@tests_names =
|
99
|
+
@tests_names = name_id_pairs(tests, 'title') if @tests_names.empty?
|
99
100
|
tests
|
100
101
|
end
|
101
102
|
|
@@ -105,8 +106,10 @@ module OnlyofficeTestrailWrapper
|
|
105
106
|
end
|
106
107
|
|
107
108
|
def add_result_by_case_id(result, case_id, comment = '', version = '')
|
108
|
-
|
109
|
-
|
109
|
+
TestrailResult.new.init_from_hash(Testrail2.http_post("index.php?/api/v2/add_result_for_case/#{@id}/#{case_id}",
|
110
|
+
status_id: TestrailResult[result],
|
111
|
+
comment: comment,
|
112
|
+
version: version))
|
110
113
|
end
|
111
114
|
|
112
115
|
def parent_suite
|
@@ -116,7 +119,9 @@ module OnlyofficeTestrailWrapper
|
|
116
119
|
def update(name = @name, description = @description)
|
117
120
|
@project.runs_names.delete @name
|
118
121
|
@project.runs_names[StringHelper.warnstrip!(name.to_s)] = @id
|
119
|
-
updated_plan =
|
122
|
+
updated_plan = TestrailRun.new.init_from_hash(Testrail2.http_post("index.php?/api/v2/update_run/#{@id}",
|
123
|
+
name: name,
|
124
|
+
description: description))
|
120
125
|
OnlyofficeLoggerHelper.log "Updated run: #{updated_plan.name}"
|
121
126
|
updated_plan
|
122
127
|
end
|
@@ -5,7 +5,7 @@ require_relative 'testrail_case'
|
|
5
5
|
module OnlyofficeTestrailWrapper
|
6
6
|
# @author Roman.Zagudaev
|
7
7
|
# Class for description of test sections
|
8
|
-
class TestrailSection
|
8
|
+
class TestrailSection < TestrailApiObject
|
9
9
|
# @return [Integer] Id of test section
|
10
10
|
attr_accessor :id
|
11
11
|
# @return [Integer] Id of parent test section
|
@@ -24,6 +24,7 @@ module OnlyofficeTestrailWrapper
|
|
24
24
|
# @param [Integer] suite_id id of test suite
|
25
25
|
# @return [TestSectionTestRail] new Test section
|
26
26
|
def initialize(name = '', parent_id = nil, suite_id = nil, id = nil)
|
27
|
+
super()
|
27
28
|
@id = id
|
28
29
|
@name = name
|
29
30
|
@suite_id = suite_id
|
@@ -46,8 +47,8 @@ module OnlyofficeTestrailWrapper
|
|
46
47
|
end
|
47
48
|
|
48
49
|
def get_case_by_id(id)
|
49
|
-
test_case =
|
50
|
-
test_case.instance_variable_set
|
50
|
+
test_case = TestrailCase.new.init_from_hash(Testrail2.http_get("index.php?/api/v2/get_case/#{id}"))
|
51
|
+
test_case.instance_variable_set :@section, self
|
51
52
|
test_case
|
52
53
|
end
|
53
54
|
|
@@ -56,7 +57,7 @@ module OnlyofficeTestrailWrapper
|
|
56
57
|
def get_cases
|
57
58
|
# raise 'Project id is not identified' if @project_id.nil?
|
58
59
|
cases = Testrail2.http_get("index.php?/api/v2/get_cases/#{@project_id}&suite_id=#{@suite_id}§ion_id=#{@id}")
|
59
|
-
@cases_names =
|
60
|
+
@cases_names = name_id_pairs(cases, 'title') if @cases_names.nil?
|
60
61
|
cases
|
61
62
|
end
|
62
63
|
|
@@ -83,9 +84,12 @@ module OnlyofficeTestrailWrapper
|
|
83
84
|
# @param [String] custom_steps steps to perform
|
84
85
|
# @return [TestCaseTestrail] created test case
|
85
86
|
def create_new_case(title, type_id = 3, priority_id = 4, custom_steps = '')
|
86
|
-
new_case =
|
87
|
-
|
88
|
-
|
87
|
+
new_case = TestrailCase.new.init_from_hash(Testrail2.http_post("index.php?/api/v2/add_case/#{@id}",
|
88
|
+
title: StringHelper.warnstrip!(title.to_s),
|
89
|
+
type_id: type_id,
|
90
|
+
priority_id: priority_id,
|
91
|
+
custom_steps: custom_steps))
|
92
|
+
new_case.instance_variable_set(:@section, self)
|
89
93
|
OnlyofficeLoggerHelper.log "Created new case: #{new_case.title}"
|
90
94
|
@cases_names[new_case.title] = new_case.id
|
91
95
|
new_case
|
@@ -94,7 +98,9 @@ module OnlyofficeTestrailWrapper
|
|
94
98
|
def update(name = @name, parent_id = @parent_id)
|
95
99
|
@suite.sections_names.delete @name
|
96
100
|
@suite.sections_names[StringHelper.warnstrip!(name.to_s)] = @id
|
97
|
-
updated_section =
|
101
|
+
updated_section = TestrailSection.new.init_from_hash(Testrail2.http_post("index.php?/api/v2/update_section/#{@id}",
|
102
|
+
name: name,
|
103
|
+
parent_id: parent_id))
|
98
104
|
OnlyofficeLoggerHelper.log "Updated section: #{updated_section.name}"
|
99
105
|
updated_section
|
100
106
|
end
|
@@ -7,7 +7,7 @@ require_relative 'testrail_run'
|
|
7
7
|
module OnlyofficeTestrailWrapper
|
8
8
|
# @author Roman.Zagudaev
|
9
9
|
# Class for description of test suites
|
10
|
-
class TestrailSuite
|
10
|
+
class TestrailSuite < TestrailApiObject
|
11
11
|
# @return [Integer] Id of test suite
|
12
12
|
attr_accessor :id
|
13
13
|
# @return [String] Name of test suite
|
@@ -28,6 +28,7 @@ module OnlyofficeTestrailWrapper
|
|
28
28
|
# @param [Integer] project_id id of project of test suite
|
29
29
|
# @return [TestrailSuite] new Test suite
|
30
30
|
def initialize(name = nil, description = nil, project_id = nil, id = nil)
|
31
|
+
super()
|
31
32
|
@id = id
|
32
33
|
@name = name
|
33
34
|
@description = description
|
@@ -39,7 +40,10 @@ module OnlyofficeTestrailWrapper
|
|
39
40
|
# @param [String] description description of test run
|
40
41
|
# @return [TestRunTestRail] created test run
|
41
42
|
def start_test_run(name, description = '')
|
42
|
-
|
43
|
+
TestrailRun.new.init_from_hash(Testrail2.http_post("index.php?/api/v2/add_run/#{@project_id}",
|
44
|
+
name: StringHelper.warnstrip!(name.to_s),
|
45
|
+
description: description,
|
46
|
+
suite_id: @id))
|
43
47
|
end
|
44
48
|
|
45
49
|
def section(name_or_id = 'All Test Cases')
|
@@ -58,12 +62,14 @@ module OnlyofficeTestrailWrapper
|
|
58
62
|
# @param [Integer] parent_section id of parent section, default = nil
|
59
63
|
def create_new_section(name, parent_section = nil)
|
60
64
|
parent_section = get_section_by_name(parent_section).id if parent_section.is_a?(String)
|
61
|
-
new_section =
|
62
|
-
|
65
|
+
new_section = TestrailSection.new.init_from_hash(Testrail2.http_post("index.php?/api/v2/add_section/#{@project_id}",
|
66
|
+
name: StringHelper.warnstrip!(name.to_s),
|
67
|
+
parent_id: parent_section,
|
68
|
+
suite_id: @id))
|
63
69
|
OnlyofficeLoggerHelper.log "Created new section: #{new_section.name}"
|
64
70
|
@sections_names[new_section.name] = new_section.id
|
65
|
-
new_section.instance_variable_set
|
66
|
-
new_section.instance_variable_set
|
71
|
+
new_section.instance_variable_set :@project_id, @project_id
|
72
|
+
new_section.instance_variable_set :@suite, self
|
67
73
|
new_section
|
68
74
|
end
|
69
75
|
|
@@ -71,14 +77,14 @@ module OnlyofficeTestrailWrapper
|
|
71
77
|
# @return [Array, TestrailSuite] array with sections
|
72
78
|
def get_sections
|
73
79
|
sections = Testrail2.http_get("index.php?/api/v2/get_sections/#{@project_id}&suite_id=#{@id}")
|
74
|
-
@sections_names =
|
80
|
+
@sections_names = name_id_pairs(sections) if @sections_names.nil?
|
75
81
|
sections
|
76
82
|
end
|
77
83
|
|
78
84
|
def get_section_by_id(id)
|
79
|
-
section =
|
80
|
-
section.instance_variable_set
|
81
|
-
section.instance_variable_set
|
85
|
+
section = TestrailSection.new.init_from_hash(Testrail2.http_get("index.php?/api/v2/get_section/#{id}"))
|
86
|
+
section.instance_variable_set :@project_id, @project_id
|
87
|
+
section.instance_variable_set :@suite, self
|
82
88
|
section
|
83
89
|
end
|
84
90
|
|
@@ -107,7 +113,9 @@ module OnlyofficeTestrailWrapper
|
|
107
113
|
def update(name, description = nil)
|
108
114
|
@project.suites_names.delete @name
|
109
115
|
@project.suites_names[StringHelper.warnstrip!(name.to_s)] = @id
|
110
|
-
updated_suite =
|
116
|
+
updated_suite = TestrailSuite.new.init_from_hash(Testrail2.http_post("index.php?/api/v2/update_suite/#{@id}",
|
117
|
+
name: name,
|
118
|
+
description: description))
|
111
119
|
OnlyofficeLoggerHelper.log "Updated suite: #{updated_suite.name}"
|
112
120
|
updated_suite
|
113
121
|
end
|
@@ -3,7 +3,8 @@
|
|
3
3
|
require_relative 'testrail_result'
|
4
4
|
|
5
5
|
module OnlyofficeTestrailWrapper
|
6
|
-
|
6
|
+
# Class for working with single testrail case
|
7
|
+
class TestrailTest < TestrailApiObject
|
7
8
|
# @return [Integer] test id
|
8
9
|
attr_accessor :id
|
9
10
|
# @return [Integer] test run id
|
@@ -18,23 +19,34 @@ module OnlyofficeTestrailWrapper
|
|
18
19
|
attr_accessor :assignedto_id
|
19
20
|
|
20
21
|
def initialize(id = nil, run_id = nil, case_id = nil, title = '')
|
22
|
+
super()
|
21
23
|
@id = id
|
22
24
|
@title = title
|
23
25
|
@case_id = case_id
|
24
26
|
@run_id = run_id
|
25
27
|
end
|
26
28
|
|
29
|
+
# Get all results of single test
|
30
|
+
# @return [Array<TestrailResult>] list of results
|
27
31
|
def get_results
|
28
32
|
@results.nil? ? @results = Testrail2.http_get("index.php?/api/v2/get_results/#{@id}") : (return @results)
|
29
|
-
@results.each_with_index { |result, index| @results[index] =
|
33
|
+
@results.each_with_index { |result, index| @results[index] = TestrailResult.new.init_from_hash(result) }
|
30
34
|
@results
|
31
35
|
end
|
32
36
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
37
|
+
# Add result to current Test
|
38
|
+
# @param [Integer, Symbol] status of result
|
39
|
+
# @param [String] comment of result
|
40
|
+
# @param [String] version of result
|
41
|
+
# @return [TestrailResult] result of adding
|
42
|
+
def add_result(status, comment = '', version = '')
|
43
|
+
status = TestrailResult::RESULT_STATUSES[status] if status.is_a?(Symbol)
|
44
|
+
result = TestrailResult.new.init_from_hash(Testrail2.http_post("index.php?/api/v2/add_result/#{@id}",
|
45
|
+
status_id: status,
|
46
|
+
comment: comment,
|
47
|
+
version: version))
|
48
|
+
OnlyofficeLoggerHelper.log "Set test result: #{status}"
|
49
|
+
result
|
38
50
|
end
|
39
51
|
end
|
40
52
|
end
|
@@ -15,7 +15,9 @@ require_relative '../testrail'
|
|
15
15
|
# TestrailTools.close_all_runs
|
16
16
|
#
|
17
17
|
module OnlyofficeTestrailWrapper
|
18
|
+
# Module for Tools for Testrail
|
18
19
|
module TestrailTools
|
20
|
+
# Class for Testrail configuration
|
19
21
|
class TestrailConfig
|
20
22
|
attr_accessor :project, :plan, :suite, :run
|
21
23
|
end
|
@@ -56,7 +58,7 @@ module OnlyofficeTestrailWrapper
|
|
56
58
|
|
57
59
|
def self.get_tests_report(status)
|
58
60
|
check_config(__method__, :@project, :@plan)
|
59
|
-
{ plan.name => plan.entries.inject({}) { |a, e| a.merge!({ e.name => e.runs.first.get_tests.
|
61
|
+
{ plan.name => plan.entries.inject({}) { |a, e| a.merge!({ e.name => e.runs.first.get_tests.filter_map { |test| test['title'] if TestrailResult::RESULT_STATUSES.key(test['status_id']) == status } }.delete_if { |_, value| value.empty? }) } }
|
60
62
|
end
|
61
63
|
|
62
64
|
def self.get_runs_durations
|
@@ -84,7 +86,7 @@ module OnlyofficeTestrailWrapper
|
|
84
86
|
end
|
85
87
|
|
86
88
|
def self.check_config(*args)
|
87
|
-
return if @testrail_config && (@testrail_config.instance_variables & args[1
|
89
|
+
return if @testrail_config && (@testrail_config.instance_variables & args[1..]) == args[1..]
|
88
90
|
|
89
91
|
raise "Method: #{args.shift} - some of needed parameters are missing: #{args.join(', ')}. To configure them, type:\n
|
90
92
|
TestrailTools.configure do |config|\n\t\tconfig.param_name = value\n\tend"
|