Class: ATM::Services::TestRun
- Defined in:
- lib/atm_ruby/services/test_run.rb
Overview
ATM::Services::TestRun provides methods for working with test runs
Instance Attribute Summary collapse
-
#environment ⇒ Object
readonly
Returns the value of attribute environment.
-
#test_run_id ⇒ Object
readonly
Returns the value of attribute test_run_id.
Attributes inherited from Base
#[], #auth_header, #header, #project_id, #response
Instance Method Summary collapse
-
#create(test_run_data) ⇒ Object
Creates new test run.
-
#create_new_test_run_result(test_run_id = @test_run_id, test_case_id, test_data) ⇒ Object
Create new result for a test run.
-
#delete(test_run_id) ⇒ Object
Delete specific test run.
-
#find(test_run_id) ⇒ Object
Retrive specific test run.
-
#initialize(**options) ⇒ TestRun
constructor
A new instance of TestRun.
- #process_result(test_data) ⇒ Object
-
#search(query_string) ⇒ Object
Searches for a testrun based on the provided quiry.
-
#update_last_test_run_result(test_run_id = @test_run_id, test_case_id, test_data) ⇒ Object
Update latest result for a test run.
Methods inherited from Base
Constructor Details
#initialize(**options) ⇒ TestRun
Returns a new instance of TestRun.
10 11 12 13 14 |
# File 'lib/atm_ruby/services/test_run.rb', line 10 def initialize(**) @test_run_id = .delete(:test_run_id) @environment = .delete(:environment) super() end |
Instance Attribute Details
#environment ⇒ Object (readonly)
Returns the value of attribute environment.
8 9 10 |
# File 'lib/atm_ruby/services/test_run.rb', line 8 def environment @environment end |
#test_run_id ⇒ Object (readonly)
Returns the value of attribute test_run_id.
8 9 10 |
# File 'lib/atm_ruby/services/test_run.rb', line 8 def test_run_id @test_run_id end |
Instance Method Details
#create(test_run_data) ⇒ Object
Creates new test run
23 24 25 26 27 28 |
# File 'lib/atm_ruby/services/test_run.rb', line 23 def create(test_run_data) self.class.post("/rest/kanoahtests/1.0/testrun", body: test_run_data.to_json, headers: auth_header).tap do |res| set_response(res) raise ATM::TestRunError, response unless code == 201 end end |
#create_new_test_run_result(test_run_id = @test_run_id, test_case_id, test_data) ⇒ Object
91 92 93 94 95 96 |
# File 'lib/atm_ruby/services/test_run.rb', line 91 def create_new_test_run_result(test_run_id = @test_run_id, test_case_id, test_data) self.class.post("/rest/kanoahtests/1.0/testrun/#{test_run_id}/testcase/#{test_case_id}/testresult", body: test_data.to_json, headers: auth_header).tap do |res| set_response(res) # raise ATM::TestRunError, response unless code == 201 end end |
#delete(test_run_id) ⇒ Object
Delete specific test run
51 52 53 54 55 56 |
# File 'lib/atm_ruby/services/test_run.rb', line 51 def delete(test_run_id) self.class.delete("/rest/kanoahtests/1.0/testrun/#{test_run_id}", headers: auth_header).tap do |res| set_response(res) raise ATM::TestRunError, response unless code == 204 end end |
#find(test_run_id) ⇒ Object
Retrive specific test run
37 38 39 40 41 42 |
# File 'lib/atm_ruby/services/test_run.rb', line 37 def find(test_run_id) self.class.get("/rest/kanoahtests/1.0/testrun/#{test_run_id}", headers: auth_header).tap do |res| set_response(res) raise ATM::TestRunError, response unless code == 200 end end |
#process_result(test_data) ⇒ Object
124 125 126 127 128 129 130 131 132 133 134 |
# File 'lib/atm_ruby/services/test_run.rb', line 124 def process_result(test_data) { 'status' => test_data[:status], 'environment' => test_data.fetch(:environment, @environment), 'comment' => test_data.fetch(:comment, nil), 'userKey' => test_data.fetch(:username, nil), 'executionTime' => test_data.fetch(:execution_time, nil), 'executionDate' => test_data.fetch(:execution_date, nil), 'scriptResults' => test_data[:script_results] }.delete_if { |k, v| v.nil? } end |
#search(query_string) ⇒ Object
Searches for a testrun based on the provided quiry
65 66 67 68 69 70 |
# File 'lib/atm_ruby/services/test_run.rb', line 65 def search(query_string) self.class.get("/rest/kanoahtests/1.0/testrun/search?query=#{query_string}", headers: auth_header).tap do |res| set_response(res) raise ATM::TestRunError, response unless code == 200 end end |
#update_last_test_run_result(test_run_id = @test_run_id, test_case_id, test_data) ⇒ Object
117 118 119 120 121 122 |
# File 'lib/atm_ruby/services/test_run.rb', line 117 def update_last_test_run_result(test_run_id = @test_run_id, test_case_id, test_data) self.class.post("/rest/kanoahtests/1.0/testrun/#{test_run_id}/testcase/#{test_case_id}/testresult", body: test_data.to_json, headers: auth_header).tap do |res| set_response(res) end # raise ATM::TestRunError, response unless response.code == 200 end |