module OnlyofficeTestrailWrapper::TestrailTools

Public Class Methods

check_config(*args) click to toggle source
# File lib/onlyoffice_testrail_wrapper/testrail_tools/testrail_tools.rb, line 86
def self.check_config(*args)
  return if @testrail_config && (@testrail_config.instance_variables & args[1..-1]) == args[1..-1]

  raise "Method: #{args.shift} - some of needed parameters are missing: #{args.join(', ')}. To configure them, type:\n
         TestrailTools.configure do |config|\n\t\tconfig.param_name = value\n\tend"
end
close_all_plans_older_than(time) click to toggle source
# File lib/onlyoffice_testrail_wrapper/testrail_tools/testrail_tools.rb, line 47
def self.close_all_plans_older_than(time)
  check_config(__method__, :@project)
  loop do
    old_plans = project.plans(is_completed: 0).reject { |e| e.created_on > time.to_i }
    return if old_plans.empty?

    old_plans.each(&:close)
  end
end
close_all_runs_older_than(time) click to toggle source
# File lib/onlyoffice_testrail_wrapper/testrail_tools/testrail_tools.rb, line 37
def self.close_all_runs_older_than(time)
  check_config(__method__, :@project)
  loop do
    old_runs = project.runs(is_completed: 0).reject { |e| e.created_on > time.to_i }
    return if old_runs.empty?

    old_runs.each(&:close)
  end
end
configure() { |testrail_config| ... } click to toggle source
# File lib/onlyoffice_testrail_wrapper/testrail_tools/testrail_tools.rb, line 23
def self.configure
  @testrail_config ||= TestrailConfig.new
  yield(@testrail_config) if block_given?
end
get_all_plans_younger_than(time) click to toggle source
# File lib/onlyoffice_testrail_wrapper/testrail_tools/testrail_tools.rb, line 32
def self.get_all_plans_younger_than(time)
  check_config(__method__, :@project)
  project.get_plans(is_completed: 0).reject { |e| e['created_on'] < time.to_i }
end
get_most_failed() click to toggle source
# File lib/onlyoffice_testrail_wrapper/testrail_tools/testrail_tools.rb, line 93
def self.get_most_failed
  failed_tests = TestrailTools.get_tests_report(:failed)[@plan.name]
  aborted_tests = TestrailTools.get_tests_report(:aborted)[@plan.name]
  untested_tests = TestrailTools.get_tests_report(:untested)[@plan.name]

  problem_tests = {}
  problem_tests = problem_tests.deep_merge(failed_tests)
  problem_tests = problem_tests.deep_merge(aborted_tests)
  problem_tests = problem_tests.deep_merge(untested_tests)
  problem_result = problem_tests.sort_by { |_key, value| value.length }.reverse
  problem_result.each do |cur|
    p cur[0]
  end
end
get_runs_durations() click to toggle source
# File lib/onlyoffice_testrail_wrapper/testrail_tools/testrail_tools.rb, line 62
def self.get_runs_durations
  check_config(__method__, :@project, :@plan)
  sorted_durations = plan.plan_durations
  sorted_durations.each do |run|
    OnlyofficeLoggerHelper.log "'#{run.first}' took about #{run[1]} hours"
  end
end
get_tests_report(status) click to toggle source
# File lib/onlyoffice_testrail_wrapper/testrail_tools/testrail_tools.rb, line 57
def self.get_tests_report(status)
  check_config(__method__, :@project, :@plan)
  { plan.name => plan.entries.inject({}) { |a, e| a.merge!({ e.name => e.runs.first.get_tests.map { |test| test['title'] if TestrailResult::RESULT_STATUSES.key(test['status_id']) == status }.compact }.delete_if { |_, value| value.empty? }) } }
end
plan() click to toggle source
# File lib/onlyoffice_testrail_wrapper/testrail_tools/testrail_tools.rb, line 78
def self.plan
  @plan ||= project.plan(@testrail_config.plan)
end
project() click to toggle source
# File lib/onlyoffice_testrail_wrapper/testrail_tools/testrail_tools.rb, line 70
def self.project
  @project ||= Testrail2.new.project(@testrail_config.project)
end
run() click to toggle source
# File lib/onlyoffice_testrail_wrapper/testrail_tools/testrail_tools.rb, line 74
def self.run
  @run ||= project.test_run(@testrail_config.run)
end
suite() click to toggle source
# File lib/onlyoffice_testrail_wrapper/testrail_tools/testrail_tools.rb, line 82
def self.suite
  @suite ||= project.suite(@testrail_config.suite)
end
testrail() click to toggle source
# File lib/onlyoffice_testrail_wrapper/testrail_tools/testrail_tools.rb, line 28
def self.testrail
  @testrail_config
end