Module: TestRail::Client::Cases
- Included in:
- API
- Defined in:
- lib/testrail_api/client/cases.rb
Overview
Methods for the Cases API
Use the following API methods to request details about test cases and to create or modify test cases.
Instance Method Summary collapse
-
#add_case(section_id, filters = {}) ⇒ Hash
Creates a new test case.
-
#case(case_id) ⇒ Hash
Returns an existing test case.
-
#cases(project_id, suite_id, filters = {}) ⇒ Object
Returns a list of test cases for a test suite or specific section in a test suite.
- #cases_by_title(title, project_id, suite_id, filters = {}) ⇒ Object
-
#cases_ids(project_id, suite_id, filters = {}) ⇒ Array
Array of cases IDs using TestRail#Client#Case#cases method (parameters are the same).
-
#delete_case(case_id) ⇒ Object
Deletes an existing test case.
-
#update_case(case_id, body = {}) ⇒ Object
Updates an existing test case (partial updates are supported, i.e. you can submit and update specific fields only).
Instance Method Details
#add_case(section_id, filters = {}) ⇒ Hash
Creates a new test case.
TODO: finish custom fields
67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/testrail_api/client/cases.rb', line 67 def add_case(section_id, filters = {}) post("add_case/#{section_id}", body: { title: filters[:title], type_id: filters[:type_id].to_list, priority_id: filters[:priority_id].to_list, estimate: filters[:estimate], milestone_id: filters[:milestone_id], refs: filters[:refs] }.to_json) end |
#case(case_id) ⇒ Hash
Returns an existing test case
13 14 15 |
# File 'lib/testrail_api/client/cases.rb', line 13 def case(case_id) get("get_case/#{case_id}") end |
#cases(project_id, suite_id, filters = {}) ⇒ Object
Returns a list of test cases for a test suite or specific section in a test suite.
The response includes an array of test cases. Each test case in this list follows the same format as TestRail#Client#Cases#case
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/testrail_api/client/cases.rb', line 37 def cases(project_id, suite_id, filters = {}) get("get_cases/#{project_id}&suite_id=#{suite_id}", params: { section_id: filters[:section_id], created_after: filters[:created_after], created_before: filters[:created_before], created_by: filters[:created_by].to_list, milestone_id: filters[:milestone_id].to_list, priority_id: filters[:priority_id].to_list, type_id: filters[:type_id].to_list, updated_after: filters[:updated_after], updated_before: filters[:updated_before], updated_by: filters[:updated_by].to_list }) end |
#cases_by_title(title, project_id, suite_id, filters = {}) ⇒ Object
84 85 86 |
# File 'lib/testrail_api/client/cases.rb', line 84 def cases_by_title(title, project_id, suite_id, filters = {}) cases(project_id, suite_id, filters).find { |test_case| test_case['title'] == title } end |
#cases_ids(project_id, suite_id, filters = {}) ⇒ Array
Returns array of cases IDs using TestRail#Client#Case#cases method (parameters are the same).
80 81 82 |
# File 'lib/testrail_api/client/cases.rb', line 80 def cases_ids(project_id, suite_id, filters = {}) cases(project_id, suite_id, filters).map { |x| x['id'] } end |
#delete_case(case_id) ⇒ Object
Deletes an existing test case. Please note: Deleting a test case cannot be undone and also permanently deletes all test results in active test runs (i.e. test runs that haven’t been closed (archived) yet).
101 102 103 |
# File 'lib/testrail_api/client/cases.rb', line 101 def delete_case(case_id) post("delete_case/#{case_id}") end |
#update_case(case_id, body = {}) ⇒ Object
Updates an existing test case (partial updates are supported, i.e. you can submit and update specific fields only). This method supports the same POST fields as TestRail#Client#Case#add_case (except section_id)
90 91 92 93 94 |
# File 'lib/testrail_api/client/cases.rb', line 90 def update_case(case_id, body = {}) body[:type_id] = body[:type_id].to_list if body[:type_id] body[:priority_id] = body[:priority_id].to_list if body[:type_id] post("update_case/#{case_id}", body: body.to_json) end |