class ATM::Services::TestCase
ATM::Services::TestCase
provides methods for working with test cases
@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_case.rb, line 13 def initialize(**options) @project_id = options.delete(:project_id) @environment = options.delete(:environment) super(options) end
Public Instance Methods
Adds attachment to a test case
@param [String] tese_case_id
@example Add attachment to an existed test case
# File lib/atm_ruby/services/test_case.rb, line 91 def add_attachment(_test_case_id) # TODO: need to fix this. warn 'Not implemented at the moment' # self.class.get("/rest/kanoahtests/1.0/testcase/#{test_case_id}/attachment", headers: auth_header).tap do |res| # raise ATM::TestCaseError, response unless response.code == 201 # end end
Creates new test case
@param [Hash] body
@example Create new test case
ATM::Client.new.TestCase.create({"projectKey": "JQA", "name": "Ensure the axial-flow pump is enabled"})
# File lib/atm_ruby/services/test_case.rb, line 26 def create(body) self.class.post('/rest/kanoahtests/1.0/testcase', body: body.to_json, headers: auth_header).tap do |res| set_response(res) raise ATM::TestCaseError, response unless code == 201 end end
Create new result for test case
@param [Hash] test_data
@example
test_data = { project: "GG", test_case: 'GG-T1'} ATM::Client.new.TestCase.create_new_test_result(test_data)
# File lib/atm_ruby/services/test_case.rb, line 106 def create_new_test_result(test_data) self.class.post('/rest/kanoahtests/1.0/testresult', body: test_data.to_json, headers: auth_header).tap do |res| set_response(res) raise ATM::TestCaseError, response unless code == 200 end end
Deletes test case
@param [String] test_case_id
@example Delete existing test case
# File lib/atm_ruby/services/test_case.rb, line 52 def delete(test_case_id) self.class.delete("/rest/kanoahtests/1.0/testcase/#{test_case_id}", headers: auth_header).tap do |res| set_response(res) raise ATM::TestCaseError, response unless code == 204 end end
Finds specific test case
@param [String] test_case_id
@example Find existing test case
# File lib/atm_ruby/services/test_case.rb, line 65 def find(test_case_id) self.class.get("/rest/kanoahtests/1.0/testcase/#{test_case_id}", headers: auth_header).tap do |res| set_response(res) raise ATM::TestCaseError, response unless code == 200 end end
Creates hash for new test result
@param [Hash] test_data
# File lib/atm_ruby/services/test_case.rb, line 116 def process_result(test_data) { 'projectKey' => test_data.fetch(:project_id, project_id), 'testCaseKey' => test_data[:test_case_id], 'status' => test_data.fetch(:status, nil), 'environment' => test_data.fetch(:environment, environment), 'userKey' => test_data.fetch(:username, nil), 'comment' => test_data.fetch(:comment, nil), 'executionTime' => test_data.fetch(:execution_time, nil), 'executionDate' => test_data.fetch(:execution_date, nil), 'scriptResults' => test_data.fetch(:script_results, nil) }.delete_if { |_k, v| v.nil? } end
Searches for test cases based on the provided quiry
@param [String] query_string
@example Search for an existed test case
# File lib/atm_ruby/services/test_case.rb, line 78 def search(query_string) self.class.get("/rest/kanoahtests/1.0/testcase/search?query=#{query_string}", headers: auth_header).tap do |res| set_response(res) raise ATM::TestCaseError, response unless code == 200 end end
Updates test case
@param [String] test_case_id
@example Update existing test case
# File lib/atm_ruby/services/test_case.rb, line 39 def update(test_case_id, body) self.class.put("/rest/kanoahtests/1.0/testcase/#{test_case_id}", body: body.to_json, headers: auth_header).tap do |res| set_response(res) raise ATM::TestCaseError, response unless code == 200 end end