Class: TestRail::Connection
- Inherits:
-
Object
- Object
- TestRail::Connection
- Defined in:
- lib/test_rail_integration/generator/connection.rb
Class Method Summary collapse
-
.cases_by_default(test_run_id) ⇒ Object
Get ID of all test cases from current test run.
- .cases_ids_by_default(test_run_id) ⇒ Object
- .cases_ids_by_type(test_run_id, type) ⇒ Object
-
.cases_with_types ⇒ Object
Take all test types.
-
.change_test_run_name(run_id = test_run_id) ⇒ Object
Changing name of test run from <test run name> in progress to <test run name>.
-
.client ⇒ Object
Creates connection to TestRail server.
-
.commit_test_result(test_case_result) ⇒ Object
Send test result to TestRail for current test run client.send_post(“add_result_for_case/<number_of test run>/<test case id>”, <result that pushes>).
-
.create_test_run_with_name(name) ⇒ Object
Create test run in test rail for project with name.
-
.get_case_info(case_id) ⇒ Object
Get info about test cases from TestRail.
-
.get_test_results(case_id) ⇒ Object
Obtaining of all previous test results for current test case.
-
.project_id ⇒ Object
Setting project id.
-
.test_run_data(id_of_run = test_run_id) ⇒ Object
Getting information about test run.
-
.test_run_id ⇒ Object
Setting test run id value.
-
.test_run_id=(test_run_id) ⇒ Object
Setting up test run id.
-
.test_run_name(id_of_run = test_run_id) ⇒ Object
Get test run name.
-
.test_suite_id ⇒ Object
Setting test suite id.
-
.update_test_run(run_id, name_of_run = nil, description = nil, assigned_to_id = nil) ⇒ Object
Update test run with fields.
-
.write_build_url(test_run_id, build_id) ⇒ Object
Write TeamCity build id to TestRail.
Class Method Details
.cases_by_default(test_run_id) ⇒ Object
Get ID of all test cases from current test run
cases = client.send_get(“get_tests/12”)
57 58 59 |
# File 'lib/test_rail_integration/generator/connection.rb', line 57 def self.cases_by_default(test_run_id) client.send_get("get_tests/#{test_run_id}") end |
.cases_ids_by_default(test_run_id) ⇒ Object
61 62 63 64 |
# File 'lib/test_rail_integration/generator/connection.rb', line 61 def self.cases_ids_by_default(test_run_id) cases = cases_by_default(test_run_id) cases.map { |test_case| test_case["case_id"]} end |
.cases_ids_by_type(test_run_id, type) ⇒ Object
66 67 68 69 |
# File 'lib/test_rail_integration/generator/connection.rb', line 66 def self.cases_ids_by_type(test_run_id, type) cases = cases_by_default(test_run_id) cases.map { |test_case| test_case["case_id"] if test_case["type_id"].equal?(type)}.compact end |
.cases_with_types ⇒ Object
Take all test types
117 118 119 120 121 122 |
# File 'lib/test_rail_integration/generator/connection.rb', line 117 def self.cases_with_types types = TYPES cases = client.send_get("get_cases/#{project_id}&suite_id=#{test_suite_id}&type_id=#{types}") case_ids = cases.map { |test_case| test_case["id"] } case_ids end |
.change_test_run_name(run_id = test_run_id) ⇒ Object
Changing name of test run from <test run name> in progress to <test run name>
VN LIVE_TEST in progress => VN LIVE_TEST
136 137 138 139 |
# File 'lib/test_rail_integration/generator/connection.rb', line 136 def self.change_test_run_name(run_id = test_run_id) new_name = test_run_name.gsub(IN_PROGRESS, "") client.send_post("update_run/#{run_id}", {name: new_name}) end |
.client ⇒ Object
Creates connection to TestRail server
client = TestRail::APIClient.new(‘<TestRail server>’,“<User email>”,“<User password>”)
22 23 24 |
# File 'lib/test_rail_integration/generator/connection.rb', line 22 def self.client @client_test_rail ||= TestRail::APIClient.new(CONNECTION_DATA) end |
.commit_test_result(test_case_result) ⇒ Object
Send test result to TestRail for current test run client.send_post(“add_result_for_case/<number_of test run>/<test case id>”, <result that pushes>)
client.send_post(“add_result_for_case/12/3131”, status_id: ‘1’, comment: “Test passed” )
32 33 34 |
# File 'lib/test_rail_integration/generator/connection.rb', line 32 def self.commit_test_result(test_case_result) client.send_post("add_result_for_case/#{test_run_id}/#{test_case_result.test_case_id}", test_case_result.to_test_rail_api) end |
.create_test_run_with_name(name) ⇒ Object
Create test run in test rail for project with name
48 49 50 |
# File 'lib/test_rail_integration/generator/connection.rb', line 48 def self.create_test_run_with_name(name) client.send_post("add_run/#{project_id}", {suite_id: test_suite_id, name: name, include_all: false, case_ids: cases_with_types}) end |
.get_case_info(case_id) ⇒ Object
Get info about test cases from TestRail
127 128 129 |
# File 'lib/test_rail_integration/generator/connection.rb', line 127 def self.get_case_info(case_id) client.send_get("get_case/#{case_id}") end |
.get_test_results(case_id) ⇒ Object
Obtaining of all previous test results for current test case
client.send_get(“get_results_for_case/12/3534”)
41 42 43 |
# File 'lib/test_rail_integration/generator/connection.rb', line 41 def self.get_test_results(case_id) client.send_get("get_results_for_case/#{test_run_id}/#{case_id}") end |
.project_id ⇒ Object
Setting project id
88 89 90 |
# File 'lib/test_rail_integration/generator/connection.rb', line 88 def self.project_id @project_id ||= PROJECT_ID end |
.test_run_data(id_of_run = test_run_id) ⇒ Object
Getting information about test run
103 104 105 |
# File 'lib/test_rail_integration/generator/connection.rb', line 103 def self.test_run_data(id_of_run=test_run_id) client.send_get("get_run/#{id_of_run}") end |
.test_run_id ⇒ Object
Setting test run id value
81 82 83 |
# File 'lib/test_rail_integration/generator/connection.rb', line 81 def self.test_run_id @test_run_id ||= TEST_RUN_ID end |
.test_run_id=(test_run_id) ⇒ Object
Setting up test run id
74 75 76 |
# File 'lib/test_rail_integration/generator/connection.rb', line 74 def self.test_run_id=(test_run_id) @test_run_id = test_run_id end |
.test_run_name(id_of_run = test_run_id) ⇒ Object
Get test run name
110 111 112 |
# File 'lib/test_rail_integration/generator/connection.rb', line 110 def self.test_run_name(id_of_run=test_run_id) test_run_data(id_of_run)["name"] end |
.test_suite_id ⇒ Object
Setting test suite id
96 97 98 |
# File 'lib/test_rail_integration/generator/connection.rb', line 96 def self.test_suite_id @test_suite_id ||= TEST_SUITE end |
.update_test_run(run_id, name_of_run = nil, description = nil, assigned_to_id = nil) ⇒ Object
Update test run with fields
144 145 146 |
# File 'lib/test_rail_integration/generator/connection.rb', line 144 def self.update_test_run(run_id, name_of_run = nil, description = nil, assigned_to_id = nil ) client.send_post("update_run/#{run_id}", {name: name_of_run, description: description, assignedto_id: assigned_to_id}) end |
.write_build_url(test_run_id, build_id) ⇒ Object
Write TeamCity build id to TestRail
151 152 153 154 |
# File 'lib/test_rail_integration/generator/connection.rb', line 151 def self.write_build_url(test_run_id, build_id) description = "Build url: #{build_id}" update_test_run(test_run_id, nil, description, nil) end |