class OnlyofficeTestrailWrapper::TestrailSuite
@author Roman.Zagudaev Class for description of test suites
Attributes
@return [String] description of test suite
@return [Integer] Id of test suite
@return [String] Name
of test suite
@return [true, false] id of project of test suite
@return [Array] sections in suite
@return [String] url to current suite
Public Class Methods
Default constructor @param [Integer] id id of test suite, default = nil @param [String] name name of test suite, default = nil @param [String] description description of test suite, default = nil @param [Integer] project_id
id of project of test suite @return [TestrailSuite] new Test suite
# File lib/onlyoffice_testrail_wrapper/testrail_suite.rb, line 30 def initialize(name = nil, description = nil, project_id = nil, id = nil) @id = id @name = name @description = description @project_id = project_id end
Public Instance Methods
Create new section of test suite @param [String] name of test section to create @param [Integer] parent_section id of parent section, default = nil
# File lib/onlyoffice_testrail_wrapper/testrail_suite.rb, line 59 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 = HashHelper.parse_to_class_variable(Testrail2.http_post("index.php?/api/v2/add_section/#{@project_id}", name: StringHelper.warnstrip!(name.to_s), parent_id: parent_section, suite_id: @id), TestrailSection) 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 current test suite @return [nil]
# File lib/onlyoffice_testrail_wrapper/testrail_suite.rb, line 100 def delete Testrail2.http_post "index.php?/api/v2/delete_suite/#{@id}", {} OnlyofficeLoggerHelper.log "Deleted suite: #{@name}" @project.suites_names.delete @name nil end
# File lib/onlyoffice_testrail_wrapper/testrail_suite.rb, line 78 def get_section_by_id(id) section = HashHelper.parse_to_class_variable(Testrail2.http_get("index.php?/api/v2/get_section/#{id}"), TestrailSection) section.instance_variable_set '@project_id', @project_id section.instance_variable_set '@suite', self section end
# File lib/onlyoffice_testrail_wrapper/testrail_suite.rb, line 85 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 all sections in test suite @return [Array, TestrailSuite] array with sections
# File lib/onlyoffice_testrail_wrapper/testrail_suite.rb, line 72 def get_sections sections = Testrail2.http_get("index.php?/api/v2/get_sections/#{@project_id}&suite_id=#{@id}") @sections_names = HashHelper.get_hash_from_array_with_two_parameters(sections, 'name', 'id') if @sections_names.nil? sections end
Init section by it's name @param [String] name name of section @return [TestrailSection] Section with this name
# File lib/onlyoffice_testrail_wrapper/testrail_suite.rb, line 93 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
# File lib/onlyoffice_testrail_wrapper/testrail_suite.rb, line 45 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 from test suite @param [String] name name of started test run @param [String] description description of test run @return [TestRunTestRail] created test run
# File lib/onlyoffice_testrail_wrapper/testrail_suite.rb, line 41 def start_test_run(name, description = '') 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) end
# File lib/onlyoffice_testrail_wrapper/testrail_suite.rb, line 107 def update(name, description = nil) @project.suites_names.delete @name @project.suites_names[StringHelper.warnstrip!(name.to_s)] = @id updated_suite = HashHelper.parse_to_class_variable(Testrail2.http_post("index.php?/api/v2/update_suite/#{@id}", name: name, description: description), TestrailSuite) OnlyofficeLoggerHelper.log "Updated suite: #{updated_suite.name}" updated_suite end