Class: TestRail::Check

Inherits:
Object
  • Object
show all
Defined in:
lib/test_rail_integration/generator/project/check.rb

Class Method Summary collapse

Class Method Details

.check_test_run_statuses(test_run_id) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/test_rail_integration/generator/project/check.rb', line 10

def self.check_test_run_statuses(test_run_id)
  start_time = Time.new
  results = []

  TestRail::Connection.test_run_id=(test_run_id)

  test_cases_ids = Connection.cases_with_types
  test_cases_ids.each do |test_case_id|

    case_info = Connection.get_case_info(test_case_id)
    scenario = Scenario.new(case_info['title'], ["@C#{test_case_id}"])
    test_case_result = TestRail::TestCaseResult.new(scenario)
    test_results = test_case_result.test_results.map { |status_hash| status_hash["status_id"] }

    if test_results.include?(TestCaseResult::COMMENT[:fail][:status]) &&
        test_results.include?(TestCaseResult::COMMENT[:pass][:status])

      if test_case_result.get_indexes_of_passes.first < test_case_result.get_indexes_of_fails.first
        test_case_result.comment ||= TestRail::TestCaseResult::COMMENT[:fail]
        TestRail::Connection.commit_test_result(test_case_result)

        p test_case_result.test_case_id
        p test_case_result.scenario.title
        results.push(test_case_result)
      end

    end
  end
  end_time = Time.now - start_time
  p "Time for run  = #{end_time} seconds"
  results
end