Class: OnlyofficeTestrailWrapper::TestrailTest

Inherits:
TestrailApiObject show all
Defined in:
lib/onlyoffice_testrail_wrapper/testrail_test.rb

Overview

Class for working with single testrail case

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from TestrailApiObject

#init_from_hash, #name_id_pairs

Constructor Details

#initialize(id = nil, run_id = nil, case_id = nil, title = '') ⇒ TestrailTest

Returns a new instance of TestrailTest.



21
22
23
24
25
26
27
# File 'lib/onlyoffice_testrail_wrapper/testrail_test.rb', line 21

def initialize(id = nil, run_id = nil, case_id = nil, title = '')
  super()
  @id = id
  @title = title
  @case_id = case_id
  @run_id = run_id
end

Instance Attribute Details

#assignedto_idInteger

Returns assigned to id.

Returns:

  • (Integer)

    assigned to id



19
20
21
# File 'lib/onlyoffice_testrail_wrapper/testrail_test.rb', line 19

def assignedto_id
  @assignedto_id
end

#case_idInteger

Returns case id.

Returns:

  • (Integer)

    case id



15
16
17
# File 'lib/onlyoffice_testrail_wrapper/testrail_test.rb', line 15

def case_id
  @case_id
end

#idInteger

Returns test id.

Returns:

  • (Integer)

    test id



9
10
11
# File 'lib/onlyoffice_testrail_wrapper/testrail_test.rb', line 9

def id
  @id
end

#run_idInteger

Returns test run id.

Returns:

  • (Integer)

    test run id



11
12
13
# File 'lib/onlyoffice_testrail_wrapper/testrail_test.rb', line 11

def run_id
  @run_id
end

#status_idInteger

Returns status id.

Returns:

  • (Integer)

    status id



13
14
15
# File 'lib/onlyoffice_testrail_wrapper/testrail_test.rb', line 13

def status_id
  @status_id
end

#titleString

Returns test title.

Returns:

  • (String)

    test title



17
18
19
# File 'lib/onlyoffice_testrail_wrapper/testrail_test.rb', line 17

def title
  @title
end

Instance Method Details

#add_result(status, comment = '', version = '') ⇒ TestrailResult

Add result to current Test

Parameters:

  • status (Integer, Symbol)

    of result

  • comment (String) (defaults to: '')

    of result

  • version (String) (defaults to: '')

    of result

Returns:



42
43
44
45
46
47
48
49
50
# File 'lib/onlyoffice_testrail_wrapper/testrail_test.rb', line 42

def add_result(status, comment = '', version = '')
  status = TestrailResult::RESULT_STATUSES[status] if status.is_a?(Symbol)
  result = TestrailResult.new.init_from_hash(Testrail2.http_post("index.php?/api/v2/add_result/#{@id}",
                                                                 status_id: status,
                                                                 comment: comment,
                                                                 version: version))
  OnlyofficeLoggerHelper.log "Set test result: #{status}"
  result
end

#get_resultsArray<TestrailResult>

Get all results of single test

Returns:



31
32
33
34
35
# File 'lib/onlyoffice_testrail_wrapper/testrail_test.rb', line 31

def get_results
  @results.nil? ? @results = Testrail2.http_get("index.php?/api/v2/get_results/#{@id}") : (return @results)
  @results.each_with_index { |result, index| @results[index] = TestrailResult.new.init_from_hash(result) }
  @results
end