class TestRail::Hook

Public Class Methods

failed_result?(result) click to toggle source
# File lib/test_rail_integration/generator/test_rail_hooks.rb, line 33
def self.failed_result?(result)
  !result
end
passed_result?(result, prev_result) click to toggle source
# File lib/test_rail_integration/generator/test_rail_hooks.rb, line 37
def self.passed_result?(result, prev_result)
  result && prev_result != TestRail::TestCaseResult::FAILED
end
unchanged_pass_result?(result, prev_result) click to toggle source
# File lib/test_rail_integration/generator/test_rail_hooks.rb, line 41
def self.unchanged_pass_result?(result, prev_result)
  result && prev_result == TestRail::TestCaseResult::FAILED
end
update_test_rail(scenario) click to toggle source

Updating Test Rail according to logic

# File lib/test_rail_integration/generator/test_rail_hooks.rb, line 11
def self.update_test_rail(scenario)
  test_case_id = scenario.source_tag_names.find { |e| e.match(TEST_RAIL_ID_REGEX) }[2..-1]

  prev_result = TestRail::Connection.get_previous_test_result(test_case_id)
  run_result = scenario.passed?
  test_case_result = TestRail::TestCaseResult.new(test_case_id, scenario.title)

  test_case_result.comment = TestRail::TestCaseResult::COMMENT[:pass] if passed_result?(run_result, prev_result)
  test_case_result.comment ||= TestRail::TestCaseResult::COMMENT[:unchanged_pass] if unchanged_pass_result?(run_result, prev_result)

  if failed_result?(run_result)
    test_case_result.comment ||= TestRail::TestCaseResult::COMMENT[:fail]
    test_case_result.exception_message = scenario.steps.exception rescue nil
    test_case_result.assign_to = TestRail::TestCaseResult::ASSIGN_TO
  end

  raise("Invalid test case result : scenario.passed? #{scenario.passed?}, prev_result? #{prev_result}, run_result? #{run_result}") if test_case_result.comment.nil?

  TestRail::Connection.commit_test_result(test_case_result)

end