class OnlyofficeTestrailWrapper::TestrailCase

@author Roman.Zagudaev Class for description of test case

Attributes

custom_steps[RW]

@return [String] Steps of test case

estimate[RW]

@return [String] Estimated test time

id[RW]

@return [Integer] Id of test case

priority_id[RW]

@return [Integer] priority id of test case

title[RW]

@return [String] title of test case

type_id[RW]

@return [Integer] type id of test case

Public Class Methods

new(title = nil, type_id = 3, priority_id = 4, custom_steps = nil, id = nil) click to toggle source

Default constructor @param [String] title name of test case, default = nil @param [Integer] type_id type id of test case, default = 3 @param [Integer] priority_id priority id of test case, default = 4 @param [String] custom_steps Steps of test case @param [Integer] id Id of test case @return [TestCaseTestrail] new test case

# File lib/onlyoffice_testrail_wrapper/testrail_case.rb, line 27
def initialize(title = nil, type_id = 3, priority_id = 4, custom_steps = nil, id = nil)
  @id = id
  @title = title
  @type_id = type_id
  @priority_id = priority_id
  @custom_steps = custom_steps
end

Public Instance Methods

add_result(run_id, result, comment = '', custom_fields = {}, version = '') click to toggle source
# File lib/onlyoffice_testrail_wrapper/testrail_case.rb, line 54
def add_result(run_id, result, comment = '', custom_fields = {}, version = '')
  response = HashHelper.parse_to_class_variable(Testrail2.http_post("index.php?/api/v2/add_result_for_case/#{run_id}/#{@id}", { status_id: TestrailResult::RESULT_STATUSES[result],
                                                                                                                                comment: comment, version: version }.merge(custom_fields)), TestrailResult)
  OnlyofficeLoggerHelper.log "Set test case result: #{result}. URL: #{Testrail2.get_testrail_address}index.php?/tests/view/#{response.test_id}", output_colors[result]
  response
end
delete() click to toggle source
# File lib/onlyoffice_testrail_wrapper/testrail_case.rb, line 42
def delete
  @section.cases_names.delete @title
  OnlyofficeLoggerHelper.log "Deleted test case: #{@title}"
  Testrail2.http_post "index.php?/api/v2/delete_case/#{@id}", {}
end
get_results(run_id) click to toggle source
# File lib/onlyoffice_testrail_wrapper/testrail_case.rb, line 48
def get_results(run_id)
  case_results = Testrail2.http_get "index.php?/api/v2/get_results_for_case/#{run_id}/#{@id}"
  case_results.each_with_index { |test_case, index| case_results[index] = HashHelper.parse_to_class_variable(test_case, TestrailResult) }
  case_results
end
update(title = @title, type_id = @type_id, priority_id = @priority_id, custom_steps = @custom_steps) click to toggle source
# File lib/onlyoffice_testrail_wrapper/testrail_case.rb, line 35
def update(title = @title, type_id = @type_id, priority_id = @priority_id, custom_steps = @custom_steps)
  @section.cases_names.delete @title
  @section.cases_names[StringHelper.warnstrip!(title.to_s)] = @id
  HashHelper.parse_to_class_variable(Testrail2.http_post("index.php?/api/v2/update_case/#{@id}", title: title, type_id: type_id,
                                                                                                 priority_id: priority_id, custom_steps: custom_steps), TestrailCase)
end

Private Instance Methods

output_colors() click to toggle source
# File lib/onlyoffice_testrail_wrapper/testrail_case.rb, line 63
def output_colors
  { failed: 45, pending: 43, passed: 42, passed_2: 46, aborted: 41, blocked: 44 }
end