Class: OnlyofficeTestrailWrapper::TestrailPlan
- Inherits:
-
TestrailApiObject
- Object
- TestrailApiObject
- OnlyofficeTestrailWrapper::TestrailPlan
- Defined in:
- lib/onlyoffice_testrail_wrapper/testrail_plan.rb
Overview
Class for working with testrail plan
Instance Attribute Summary collapse
-
#created_on ⇒ Integer
readonly
Time since epoch on which plan created.
-
#description ⇒ String
Test plan description.
-
#entries ⇒ Array
Test plan entries(Suites).
-
#error ⇒ String
readonly
Error message if any happens.
-
#id ⇒ Integer
Id of test plan.
-
#is_completed ⇒ True, False
Completed this test plan or not.
-
#milestone_id ⇒ Integer
Milestone id.
-
#name ⇒ String
Test run name.
-
#project_id ⇒ Integer
Id of project.
-
#url ⇒ String
readonly
Url to current test plan.
Instance Method Summary collapse
- #add_entry(name, suite_id, include_all = true, case_ids = [], assigned_to = nil) ⇒ Object
-
#close ⇒ nil
Close current plan.
-
#delete ⇒ nil
Delete current plan.
- #delete_entry(entry_id) ⇒ Object
-
#initialize(name = '', entries = [], description = '', milestone_id = nil, id = nil) ⇒ TestrailPlan
constructor
A new instance of TestrailPlan.
-
#plan_durations ⇒ Array
Generate array of durations of runs.
-
#run(run_name) ⇒ Object
Get run from plan.
-
#runs ⇒ Array, TestrailRuns
Get all runs in current plan.
- #tests_results ⇒ Object
Methods inherited from TestrailApiObject
#init_from_hash, #name_id_pairs
Constructor Details
#initialize(name = '', entries = [], description = '', milestone_id = nil, id = nil) ⇒ TestrailPlan
Returns a new instance of TestrailPlan.
29 30 31 32 33 34 35 36 |
# File 'lib/onlyoffice_testrail_wrapper/testrail_plan.rb', line 29 def initialize(name = '', entries = [], description = '', milestone_id = nil, id = nil) super() @name = name @entries = entries @description = description @milestone_id = milestone_id @id = id end |
Instance Attribute Details
#created_on ⇒ Integer (readonly)
Returns time since epoch on which plan created.
23 24 25 |
# File 'lib/onlyoffice_testrail_wrapper/testrail_plan.rb', line 23 def created_on @created_on end |
#description ⇒ String
Returns test plan description.
15 16 17 |
# File 'lib/onlyoffice_testrail_wrapper/testrail_plan.rb', line 15 def description @description end |
#entries ⇒ Array
Returns test plan entries(Suites).
17 18 19 |
# File 'lib/onlyoffice_testrail_wrapper/testrail_plan.rb', line 17 def entries @entries end |
#error ⇒ String (readonly)
Returns error message if any happens.
27 28 29 |
# File 'lib/onlyoffice_testrail_wrapper/testrail_plan.rb', line 27 def error @error end |
#id ⇒ Integer
Returns Id of test plan.
9 10 11 |
# File 'lib/onlyoffice_testrail_wrapper/testrail_plan.rb', line 9 def id @id end |
#is_completed ⇒ True, False
Returns Completed this test plan or not.
21 22 23 |
# File 'lib/onlyoffice_testrail_wrapper/testrail_plan.rb', line 21 def is_completed @is_completed end |
#milestone_id ⇒ Integer
Returns milestone id.
19 20 21 |
# File 'lib/onlyoffice_testrail_wrapper/testrail_plan.rb', line 19 def milestone_id @milestone_id end |
#name ⇒ String
Returns test run name.
11 12 13 |
# File 'lib/onlyoffice_testrail_wrapper/testrail_plan.rb', line 11 def name @name end |
#project_id ⇒ Integer
Returns Id of project.
13 14 15 |
# File 'lib/onlyoffice_testrail_wrapper/testrail_plan.rb', line 13 def project_id @project_id end |
#url ⇒ String (readonly)
Returns url to current test plan.
25 26 27 |
# File 'lib/onlyoffice_testrail_wrapper/testrail_plan.rb', line 25 def url @url end |
Instance Method Details
#add_entry(name, suite_id, include_all = true, case_ids = [], assigned_to = nil) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/onlyoffice_testrail_wrapper/testrail_plan.rb', line 38 def add_entry(name, suite_id, include_all = true, case_ids = [], assigned_to = nil) entry = TestrailPlanEntry.new.init_from_hash(Testrail2.http_post("index.php?/api/v2/add_plan_entry/#{@id}", suite_id: suite_id, name: StringHelper.warnstrip!(name.to_s), include_all: include_all, case_ids: case_ids, assigned_to: assigned_to)) OnlyofficeLoggerHelper.log "Added plan entry: #{name.to_s.strip}" entry.runs.each_with_index { |run, index| entry.runs[index] = TestrailRun.new.init_from_hash(run) } entry end |
#close ⇒ nil
Close current plan
64 65 66 67 68 |
# File 'lib/onlyoffice_testrail_wrapper/testrail_plan.rb', line 64 def close Testrail2.http_post("index.php?/api/v2/close_plan/#{@id}") OnlyofficeLoggerHelper.log("Closed plan: #{@name} with id #{@id}") nil end |
#delete ⇒ nil
Delete current plan
56 57 58 59 60 |
# File 'lib/onlyoffice_testrail_wrapper/testrail_plan.rb', line 56 def delete Testrail2.http_post "index.php?/api/v2/delete_plan/#{@id}", {} OnlyofficeLoggerHelper.log "Deleted plan: #{@name}" nil end |
#delete_entry(entry_id) ⇒ Object
50 51 52 |
# File 'lib/onlyoffice_testrail_wrapper/testrail_plan.rb', line 50 def delete_entry(entry_id) Testrail2.http_post "index.php?/api/v2/delete_plan_entry/#{@id}/#{entry_id}", {} end |
#plan_durations ⇒ Array
Generate array of durations of runs
104 105 106 107 108 109 110 |
# File 'lib/onlyoffice_testrail_wrapper/testrail_plan.rb', line 104 def plan_durations durations_hash = {} runs.each do |current_run| durations_hash[current_run.name] = current_run.duration end durations_hash.sort_by { |_, time| time }.reverse end |
#run(run_name) ⇒ Object
Get run from plan
84 85 86 87 88 89 90 |
# File 'lib/onlyoffice_testrail_wrapper/testrail_plan.rb', line 84 def run(run_name) @entries.each do |entry| run = entry.runs.first return run if run.name == run_name end nil end |
#runs ⇒ Array, TestrailRuns
Get all runs in current plan
94 95 96 97 98 99 100 |
# File 'lib/onlyoffice_testrail_wrapper/testrail_plan.rb', line 94 def runs runs = [] @entries.each do |entry| runs << entry.runs.first end runs end |
#tests_results ⇒ Object
70 71 72 73 74 75 76 77 78 79 |
# File 'lib/onlyoffice_testrail_wrapper/testrail_plan.rb', line 70 def tests_results run_results = {} @entries.each do |current_entrie| current_entrie.runs.each do |current_run| current_run.pull_tests_results run_results.merge!(current_run.name => current_run.test_results) end end run_results end |