class OnlyofficeTestrailWrapper::TestrailPlan

Attributes

created_on[R]

@return [Integer] time since epoch on which plan created

description[RW]

@return [String] test plan description

entries[RW]

@return [Array] test plan entries(Suites)

error[R]

@return [String] error message if any happens

id[RW]

@return [Integer] Id of test plan

is_completed[RW]

@return [True, False] Completed this test plan or not

milestone_id[RW]

@return [Integer] milestone id

name[RW]

@return [String] test run name

project_id[RW]

@return [Integer] Id of project

url[R]

@return [String] url to current test plan

Public Class Methods

new(name = '', entries = [], description = '', milestone_id = nil, id = nil) click to toggle source
# File lib/onlyoffice_testrail_wrapper/testrail_plan.rb, line 28
def initialize(name = '', entries = [], description = '', milestone_id = nil, id = nil)
  @name = name
  @entries = entries
  @description = description
  @milestone_id = milestone_id
  @id = id
end

Public Instance Methods

add_entry(name, suite_id, include_all = true, case_ids = [], assigned_to = nil) click to toggle source
# File lib/onlyoffice_testrail_wrapper/testrail_plan.rb, line 36
def add_entry(name, suite_id, include_all = true, case_ids = [], assigned_to = nil)
  entry = HashHelper.parse_to_class_variable(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), TestrailPlanEntry)
  OnlyofficeLoggerHelper.log "Added plan entry: #{name.to_s.strip}"
  entry.runs.each_with_index { |run, index| entry.runs[index] = HashHelper.parse_to_class_variable(run, TestrailRun) }
  entry
end
close() click to toggle source

Close current plan @return [nil]

# File lib/onlyoffice_testrail_wrapper/testrail_plan.rb, line 58
def close
  Testrail2.http_post("index.php?/api/v2/close_plan/#{@id}")
  OnlyofficeLoggerHelper.log("Closed plan: #{@name} with id #{@id}")
  nil
end
delete() click to toggle source

Delete current plan @return [nil]

# File lib/onlyoffice_testrail_wrapper/testrail_plan.rb, line 50
def delete
  Testrail2.http_post "index.php?/api/v2/delete_plan/#{@id}", {}
  OnlyofficeLoggerHelper.log "Deleted plan: #{@name}"
  nil
end
delete_entry(entry_id) click to toggle source
# File lib/onlyoffice_testrail_wrapper/testrail_plan.rb, line 44
def delete_entry(entry_id)
  Testrail2.http_post "index.php?/api/v2/delete_plan_entry/#{@id}/#{entry_id}", {}
end
plan_durations() click to toggle source

Generate array of durations of runs @return [Array] array of durations, sorted by descrease

# File lib/onlyoffice_testrail_wrapper/testrail_plan.rb, line 98
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) click to toggle source

Get run from plan @param run_name [String] run to find @return TestrailRun

# File lib/onlyoffice_testrail_wrapper/testrail_plan.rb, line 78
def run(run_name)
  @entries.each do |entry|
    run = entry.runs.first
    return run if run.name == run_name
  end
  nil
end
runs() click to toggle source

Get all runs in current plan @return [Array, TestrailRuns]

# File lib/onlyoffice_testrail_wrapper/testrail_plan.rb, line 88
def runs
  runs = []
  @entries.each do |entry|
    runs << entry.runs.first
  end
  runs
end
tests_results() click to toggle source
# File lib/onlyoffice_testrail_wrapper/testrail_plan.rb, line 64
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