Module: TestRail::Client::Results

Included in:
API
Defined in:
lib/testrail_api/client/results.rb

Overview

Methods for the Results API Use the following API methods to request details about test results and to add new test results.

Instance Method Summary collapse

Instance Method Details

#add_result(test_id, data = {}) ⇒ Object

TODO: add custom fields docs

Adds a new test result, comment or assigns a test. It’s recommended to use #add_results instead if you plan to add results for multiple tests.

following IDs: 1 Passed 2 Blocked 3 Untested (not allowed when adding a result) 4 Retest 5 Failed You can get a full list of system and custom statuses via #TestRail#Client#Statuses#get_statuses.

Parameters:

  • test_id (Integer, String)

    The ID of the test the result should be added to

  • data (Hash) (defaults to: {})

    : Optional query data

Options Hash (data):

  • :status_id (Integer, String)

    The ID of the test status. The built-in system statuses have the

  • :comment (String)

    The comment / description for the test result

  • :version (String)

    The version or build you tested against

  • :elapsed (String)

    The time it took to execute the test, e.g. “30s” or “1m 45s”

  • :defects (Array<Integer>, Array<String>)

    A comma-separated list of defects to link to the test result

  • :assignedto_id (Integer, String)

    The ID of a user the test should be assigned to

Returns:

  • the new test result using the same response format as get_results, but with a single result instead of a list of results.

See Also:



67
68
69
# File 'lib/testrail_api/client/results.rb', line 67

def add_result(test_id, data = {})
  post("add_result/#{test_id}", body: data.to_json)
end

#add_result_for_case(run_id, case_id, data = {}) ⇒ Object

Adds a new test result, comment or assigns a test (for a test run and case combination). It’s recommended to use add_results_for_cases instead if you plan to add results for multiple test cases. The difference to add_result is that this method expects a test run + test case instead of a test. In TestRail, tests are part of a test run and the test cases are part of the related test suite. So, when you create a new test run, TestRail creates a test for each test case found in the test suite of the run. You can therefore think of a test as an “instance” of a test case which can have test results, comments and a test status. Please also see TestRail’s getting started guide for more details about the differences between test cases and tests.

This method supports the same POST fields as add_result.

:run_id The ID of the test run :case_id The ID of the test case



85
86
87
# File 'lib/testrail_api/client/results.rb', line 85

def add_result_for_case(run_id, case_id, data = {})
  post("add_result_for_case/#{run_id}/#{case_id}", body: data.to_json)
end

#add_results(run_id, data = {}) ⇒ Object

Adds a new test result, comment or assigns a test. It’s recommended to use add_results instead if you plan to add results for multiple tests.

:run_id The ID of the test run



95
96
97
# File 'lib/testrail_api/client/results.rb', line 95

def add_results(run_id, data = {})
  post("add_results/#{run_id}", body: data.to_json)
end

#add_results_for_cases(run_id, data = {}) ⇒ Object

Adds one or more new test results, comments or assigns one or more tests (using the case IDs). Ideal for test automation to bulk-add multiple test results in one step.

:run_id The ID of the test run the results should be added to



105
106
107
# File 'lib/testrail_api/client/results.rb', line 105

def add_results_for_cases(run_id, data = {})
  post("add_results_for_cases/#{run_id}", body: data.to_json)
end

#results(test_id) ⇒ Object

Returns a list of test results for a test.

Parameters:

  • test_id (Integer, String)

    The ID of the test

Returns:

  • a list of test results for a test

See Also:



15
16
17
# File 'lib/testrail_api/client/results.rb', line 15

def results(test_id)
  get("get_results/#{test_id}")
end

#results_for_case(run_id, case_id) ⇒ Object

Returns a list of test results for a test run and case combination. The difference to get_results is that this method expects a test run + test case instead of a test. In TestRail, tests are part of a test run and the test cases are part of the related test suite. So, when you create a new test run, TestRail creates a test for each test case found in the test suite of the run. You can therefore think of a test as an “instance” of a test case which can have test results, comments and a test status. Please also see TestRail’s getting started guide for more details about the differences between test cases and tests.

This method uses the same response format as get_results.

:run_id The ID of the test run :case_id The ID of the test case



32
33
34
# File 'lib/testrail_api/client/results.rb', line 32

def results_for_case(run_id, case_id)
  get("get_results_for_case/#{run_id}/#{case_id}")
end

#results_for_run(run_id) ⇒ Object

Returns a list of test results for a test run.

:run_id The ID of the test run



41
42
43
# File 'lib/testrail_api/client/results.rb', line 41

def results_for_run(run_id)
  get("get_results_for_run/#{run_id}")
end