class TestRail::Adaptor

Public Class Methods

new( enabled: true, test_suite: nil, url:, username:, password:, project_id:, suite_id: ) click to toggle source
# File lib/testrail/adaptor.rb, line 22
def initialize(
  enabled: true,
  test_suite: nil,
  url:,
  username:,
  password:,
  project_id:,
  suite_id:
)
  @enabled = enabled
  return unless @enabled
  if test_suite.nil?
    testrail_client = TestRail::APIClient.new(url)
    testrail_client.user = username
    testrail_client.password = password
    @test_suite = TestRail::TestRailClient.new(testrail_client).get_suite(
      project_id: project_id,
      suite_id: suite_id
    )
  else
    @test_suite = test_suite
  end
end

Public Instance Methods

end_test_run() click to toggle source

Checks to see if any of the tests in a particular test run have failed, if they have then the it will leave the run opened. If there are no failed tests then it will call close the particular run.

# File lib/testrail/adaptor.rb, line 65
def end_test_run
  return if !@enabled || @test_run.nil?
  @test_run.submit_results
  @test_run.close unless @test_run.failure_count > 0
end
start_test_run() click to toggle source

This method initiates a test run against a project, and specified testsuite. ruby functional test file (.rb) containing a range of test cases. Each test case (in the ruby functional test file) will have a corresponding Test Case in TestRail. These Test Rail test cases will belong to a test suite that has the title of the corresponding ruby functional test file.

# File lib/testrail/adaptor.rb, line 58
def start_test_run
  return unless @enabled
  @test_run = @test_suite.start_test_run
end
submit(_test) click to toggle source

A new test result is submitted to TestRails. The type of test depends on the Test Suite Each adaptor implementation should be able to determine the required information from the test provided as a parameter

# File lib/testrail/adaptor.rb, line 49
def submit(_test)
  raise 'submit should be overrided by Adaptor implementations'
end

Protected Instance Methods

submit_test_result( section_name:, test_name:, success:, comment: ) click to toggle source
# File lib/testrail/adaptor.rb, line 73
def submit_test_result(
  section_name:,
  test_name:,
  success:,
  comment:
)
  @test_run.add_test_result(
    section_name: section_name,
    test_name: test_name,
    success: success,
    comment: comment
  )
end