class ATM::Services::TestRun
ATM::Services::TestRun
provides methods for working with test runs
@see www.kanoah.com/docs/public-api/1.0/ more info regarding test cases can be found here
Attributes
Public Class Methods
ATM::Services::Base::new
# File lib/atm_ruby/services/test_run.rb, line 10 def initialize(**options) @test_run_id = options.delete(:test_run_id) @environment = options.delete(:environment) super(options) end
Public Instance Methods
Creates new test run
@param [Hash] test_run_data
@example Create new test case
ATM::Client.new.TestRun.create({"name": "Full regression","projectKey": "JQA"})
# 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 result for a test run
@param [String] test_run_id
@param [String] test_case_id @param [Hash] test_data
@example
test_data = { "status": "Fail", "scriptResults": [ { "index": 0, "status": "Fail", "comment": "This steps has failed." } ]
}
ATM::Client.new.TestRun.create_new_test_run_result('DD-R123','DD-T123', test_data)
# 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 specific test run
@param [String] test_run_id
@example Create new test case
ATM::Client.new.TestRun.delete('DD-R123')
# 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
Retrive specific test run
@param [String] test_run_id
@example Create new test case
ATM::Client.new.TestRun.find('DD-R123')
# 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
# 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
Searches for a testrun based on the provided quiry
@param [String] test_run_id
@example Create new test case
ATM::Client.new.TestRun.search('projectKey = "JQA"')
# 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 latest result for a test run
@param [String] test_run_id
@param [String] test_case_id @param [Hash] test_data
@example
test_data = { "status": "Fail", "scriptResults": [ { "index": 0, "status": "Fail", "comment": "This steps has failed." } ]
}
ATM::Client.new.TestRun.update_last_test_run_result('DD-R123','DD-T123', test_data)
# 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