Module: TestRailQueries

Defined in:
lib/files/testrail_queries.rb

Overview

Test case printing and inspections

Class Method Summary collapse

Class Method Details

Prints to the console all the test plans in bridge



84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/files/testrail_queries.rb', line 84

def self.print_all_test_plans
  test_plans = TestRailOperations.get_test_rail_plans
  count_plans = 0
  test_plans.each do |plan|
    id = plan["id"]
    puts "Plan: ID: #{id}, #{plan["name"]}"
    count_plans += 1
    pjson = TestRailOperations.get_test_rail_plan(id)
    puts "    passed: #{pjson["passed_count"]}, failed: #{pjson["failed_count"]}, retest: #{pjson["retest_count"]}, blocked: #{pjson["blocked_count"]}"
    puts "    entries count: #{pjson["entries"].count}"
    pjson["entries"].each do |entry|
      puts "    entry: #{entry["id"]} - #{entry["name"]}"
    end
  end
  puts "========================================"
  puts "Total Test Plans: #{count_plans}"
end

Prints to the console, all the test runs



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/files/testrail_queries.rb', line 62

def self.print_all_test_runs
  test_runs = TestRailOperations.get_test_rail_runs
  count_runs  = 0
  count_open  = 0
  count_close = 0
  test_runs.each do |test_run|
    puts "Run: #{test_run["name"]}, id: #{test_run["id"]} complete: #{test_run["is_completed"]} "
    if test_run["is_completed"]
      count_close += 1
    else
      count_open += 1
    end

    count_runs += 1
  end
  puts "========================================"
  puts "Total Test Runs: #{count_runs}"
  puts "Total Open: #{count_open}"
  puts "Total Closed: #{count_close}"
end


102
103
104
105
106
107
# File 'lib/files/testrail_queries.rb', line 102

def self.print_all_users
  users = TestRailOperations.get_test_rail_users
  users.each do |user|
    puts user
  end
end

Prints to the console, the test cases that work on phone devices. (Sorted by test ID)



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/files/testrail_queries.rb', line 30

def self.print_phone_test_cases
  test_cases = TestRailOperations.get_test_rail_cases

  phones = []
  test_cases.values.each do |tc|
    phones << tc if tc.screen_size == "Phone"
  end

  sorted_ids = phones.each do |tc|
    tc.id
  end

  sorted_ids.each do |tc|
    tc.print
  end

  puts "Number Test Cases: #{test_cases.size}"
  puts "Number Test Cases Phone: #{phones.size}"
  percentage = (phones.size / test_cases.size.to_f) * 100.0
  puts "Percentage Phone #{percentage.round(1)}%"
end

Prints to the console, the test cases sorted by priority (ascending).



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/files/testrail_queries.rb', line 11

def self.print_priority_sorted_test_cases
  test_cases = TestRailOperations.get_test_rail_cases
  sorted_cases = test_cases.values.sort_by do |tc|
    tc.priority
  end

  automated_count = 0
  sorted_cases.each do |tc|
    tc.print
    automated_count += 1 if tc.automated
  end

  puts "Number Test Cases: #{test_cases.size}"
  puts "Number Test Cases Automated: #{automated_count}"
  percentage = (automated_count / test_cases.size.to_f) * 100.0
  puts "Percentage Automated #{percentage.round(1)}%"
end

Prints to the console, all the test case ID’s and the minimum screen size they work on



53
54
55
56
57
58
59
# File 'lib/files/testrail_queries.rb', line 53

def self.print_test_case_devices
  test_cases = TestRailOperations.get_test_rail_cases

  test_cases.each do |key, value|
    puts "ID: #{key}, #{value.screen_size}"
  end
end