Class: OnlyofficeTestrailWrapper::TestrailSuite
- Inherits:
-
TestrailApiObject
- Object
- TestrailApiObject
- OnlyofficeTestrailWrapper::TestrailSuite
- Defined in:
- lib/onlyoffice_testrail_wrapper/testrail_suite.rb
Overview
Class for description of test suites
Instance Attribute Summary collapse
-
#description ⇒ String
Description of test suite.
-
#id ⇒ Integer
Id of test suite.
-
#name ⇒ String
Name of test suite.
-
#project_id ⇒ true, false
Id of project of test suite.
-
#sections_names ⇒ Array
Sections in suite.
-
#url ⇒ String
readonly
Url to current suite.
Instance Method Summary collapse
-
#create_new_section(name, parent_section = nil) ⇒ Object
Create new section of test suite.
-
#delete ⇒ nil
Delete current test suite.
- #get_section_by_id(id) ⇒ Object
- #get_section_by_name(name) ⇒ Object
-
#get_sections ⇒ Array, TestrailSuite
Get all sections in test suite.
-
#init_section_by_name(name, parent_section = nil) ⇒ TestrailSection
Init section by it’s name.
-
#initialize(name = nil, description = nil, project_id = nil, id = nil) ⇒ TestrailSuite
constructor
Default constructor.
- #section(name_or_id = 'All Test Cases') ⇒ Object
-
#start_test_run(name, description = '') ⇒ TestRunTestRail
Start test run from test suite.
- #update(name, description = nil) ⇒ Object
Methods inherited from TestrailApiObject
#init_from_hash, #name_id_pairs
Constructor Details
#initialize(name = nil, description = nil, project_id = nil, id = nil) ⇒ TestrailSuite
Default constructor
30 31 32 33 34 35 36 |
# File 'lib/onlyoffice_testrail_wrapper/testrail_suite.rb', line 30 def initialize(name = nil, description = nil, project_id = nil, id = nil) super() @id = id @name = name @description = description @project_id = project_id end |
Instance Attribute Details
#description ⇒ String
Returns description of test suite.
16 17 18 |
# File 'lib/onlyoffice_testrail_wrapper/testrail_suite.rb', line 16 def description @description end |
#id ⇒ Integer
Returns Id of test suite.
12 13 14 |
# File 'lib/onlyoffice_testrail_wrapper/testrail_suite.rb', line 12 def id @id end |
#name ⇒ String
Returns Name of test suite.
14 15 16 |
# File 'lib/onlyoffice_testrail_wrapper/testrail_suite.rb', line 14 def name @name end |
#project_id ⇒ true, false
Returns id of project of test suite.
18 19 20 |
# File 'lib/onlyoffice_testrail_wrapper/testrail_suite.rb', line 18 def project_id @project_id end |
#sections_names ⇒ Array
Returns sections in suite.
20 21 22 |
# File 'lib/onlyoffice_testrail_wrapper/testrail_suite.rb', line 20 def sections_names @sections_names end |
#url ⇒ String (readonly)
Returns url to current suite.
22 23 24 |
# File 'lib/onlyoffice_testrail_wrapper/testrail_suite.rb', line 22 def url @url end |
Instance Method Details
#create_new_section(name, parent_section = nil) ⇒ Object
Create new section of test suite
63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/onlyoffice_testrail_wrapper/testrail_suite.rb', line 63 def create_new_section(name, parent_section = nil) parent_section = get_section_by_name(parent_section).id if parent_section.is_a?(String) new_section = TestrailSection.new.init_from_hash(Testrail2.http_post("index.php?/api/v2/add_section/#{@project_id}", name: StringHelper.warnstrip!(name.to_s), parent_id: parent_section, suite_id: @id)) OnlyofficeLoggerHelper.log "Created new section: #{new_section.name}" @sections_names[new_section.name] = new_section.id new_section.instance_variable_set :@project_id, @project_id new_section.instance_variable_set :@suite, self new_section end |
#delete ⇒ nil
Delete current test suite
106 107 108 109 110 111 |
# File 'lib/onlyoffice_testrail_wrapper/testrail_suite.rb', line 106 def delete Testrail2.http_post "index.php?/api/v2/delete_suite/#{@id}", {} OnlyofficeLoggerHelper.log "Deleted suite: #{@name}" @project.suites_names.delete @name nil end |
#get_section_by_id(id) ⇒ Object
84 85 86 87 88 89 |
# File 'lib/onlyoffice_testrail_wrapper/testrail_suite.rb', line 84 def get_section_by_id(id) section = TestrailSection.new.init_from_hash(Testrail2.http_get("index.php?/api/v2/get_section/#{id}")) section.instance_variable_set :@project_id, @project_id section.instance_variable_set :@suite, self section end |
#get_section_by_name(name) ⇒ Object
91 92 93 94 |
# File 'lib/onlyoffice_testrail_wrapper/testrail_suite.rb', line 91 def get_section_by_name(name) get_sections if @sections_names.nil? @sections_names[StringHelper.warnstrip!(name.to_s)].nil? ? nil : get_section_by_id(@sections_names[name]) end |
#get_sections ⇒ Array, TestrailSuite
Get all sections in test suite
78 79 80 81 82 |
# File 'lib/onlyoffice_testrail_wrapper/testrail_suite.rb', line 78 def get_sections sections = Testrail2.http_get("index.php?/api/v2/get_sections/#{@project_id}&suite_id=#{@id}") @sections_names = name_id_pairs(sections) if @sections_names.nil? sections end |
#init_section_by_name(name, parent_section = nil) ⇒ TestrailSection
Init section by it’s name
99 100 101 102 |
# File 'lib/onlyoffice_testrail_wrapper/testrail_suite.rb', line 99 def init_section_by_name(name, parent_section = nil) found_section = get_section_by_name name found_section.nil? ? create_new_section(name, parent_section) : found_section end |
#section(name_or_id = 'All Test Cases') ⇒ Object
49 50 51 52 53 54 55 56 57 58 |
# File 'lib/onlyoffice_testrail_wrapper/testrail_suite.rb', line 49 def section(name_or_id = 'All Test Cases') case name_or_id.class.to_s when 'Fixnum' get_section_by_id name_or_id when 'String' init_section_by_name name_or_id else raise 'Wrong argument. Must be name [String] or id [Integer]' end end |
#start_test_run(name, description = '') ⇒ TestRunTestRail
Start test run from test suite
42 43 44 45 46 47 |
# File 'lib/onlyoffice_testrail_wrapper/testrail_suite.rb', line 42 def start_test_run(name, description = '') TestrailRun.new.init_from_hash(Testrail2.http_post("index.php?/api/v2/add_run/#{@project_id}", name: StringHelper.warnstrip!(name.to_s), description: description, suite_id: @id)) end |
#update(name, description = nil) ⇒ Object
113 114 115 116 117 118 119 120 121 |
# File 'lib/onlyoffice_testrail_wrapper/testrail_suite.rb', line 113 def update(name, description = nil) @project.suites_names.delete @name @project.suites_names[StringHelper.warnstrip!(name.to_s)] = @id updated_suite = TestrailSuite.new.init_from_hash(Testrail2.http_post("index.php?/api/v2/update_suite/#{@id}", name: name, description: description)) OnlyofficeLoggerHelper.log "Updated suite: #{updated_suite.name}" updated_suite end |