Class: OnlyofficeTestrailWrapper::TestrailCase

Inherits:
Object
  • Object
show all
Defined in:
lib/onlyoffice_testrail_wrapper/testrail_case.rb

Overview

Class for description of test case

Author:

  • Roman.Zagudaev

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(title = nil, type_id = 3, priority_id = 4, custom_steps = nil, id = nil) ⇒ TestCaseTestrail

Default constructor

Parameters:

  • title (String) (defaults to: nil)

    name of test case, default = nil

  • type_id (Integer) (defaults to: 3)

    type id of test case, default = 3

  • priority_id (Integer) (defaults to: 4)

    priority id of test case, default = 4

  • custom_steps (String) (defaults to: nil)

    Steps of test case

  • id (Integer) (defaults to: nil)

    Id of test case



27
28
29
30
31
32
33
# File 'lib/onlyoffice_testrail_wrapper/testrail_case.rb', line 27

def initialize(title = nil, type_id = 3, priority_id = 4, custom_steps = nil, id = nil)
  @id = id
  @title = title
  @type_id = type_id
  @priority_id = priority_id
  @custom_steps = custom_steps
end

Instance Attribute Details

#custom_stepsString

Returns Steps of test case.

Returns:

  • (String)

    Steps of test case



16
17
18
# File 'lib/onlyoffice_testrail_wrapper/testrail_case.rb', line 16

def custom_steps
  @custom_steps
end

#estimateString

Returns Estimated test time.

Returns:

  • (String)

    Estimated test time



18
19
20
# File 'lib/onlyoffice_testrail_wrapper/testrail_case.rb', line 18

def estimate
  @estimate
end

#idInteger

Returns Id of test case.

Returns:

  • (Integer)

    Id of test case



8
9
10
# File 'lib/onlyoffice_testrail_wrapper/testrail_case.rb', line 8

def id
  @id
end

#priority_idInteger

Returns priority id of test case.

Returns:

  • (Integer)

    priority id of test case



14
15
16
# File 'lib/onlyoffice_testrail_wrapper/testrail_case.rb', line 14

def priority_id
  @priority_id
end

#titleString

Returns title of test case.

Returns:

  • (String)

    title of test case



10
11
12
# File 'lib/onlyoffice_testrail_wrapper/testrail_case.rb', line 10

def title
  @title
end

#type_idInteger

Returns type id of test case.

Returns:

  • (Integer)

    type id of test case



12
13
14
# File 'lib/onlyoffice_testrail_wrapper/testrail_case.rb', line 12

def type_id
  @type_id
end

Instance Method Details

#add_result(run_id, result, comment = '', custom_fields = {}, version = '') ⇒ Object



54
55
56
57
58
59
# File 'lib/onlyoffice_testrail_wrapper/testrail_case.rb', line 54

def add_result(run_id, result, comment = '', custom_fields = {}, version = '')
  response = HashHelper.parse_to_class_variable(Testrail2.http_post("index.php?/api/v2/add_result_for_case/#{run_id}/#{@id}", { status_id: TestrailResult::RESULT_STATUSES[result],
                                                                                                                                comment: comment, version: version }.merge(custom_fields)), TestrailResult)
  OnlyofficeLoggerHelper.log "Set test case result: #{result}. URL: #{Testrail2.get_testrail_address}index.php?/tests/view/#{response.test_id}", output_colors[result]
  response
end

#deleteObject



42
43
44
45
46
# File 'lib/onlyoffice_testrail_wrapper/testrail_case.rb', line 42

def delete
  @section.cases_names.delete @title
  OnlyofficeLoggerHelper.log "Deleted test case: #{@title}"
  Testrail2.http_post "index.php?/api/v2/delete_case/#{@id}", {}
end

#get_results(run_id) ⇒ Object



48
49
50
51
52
# File 'lib/onlyoffice_testrail_wrapper/testrail_case.rb', line 48

def get_results(run_id)
  case_results = Testrail2.http_get "index.php?/api/v2/get_results_for_case/#{run_id}/#{@id}"
  case_results.each_with_index { |test_case, index| case_results[index] = HashHelper.parse_to_class_variable(test_case, TestrailResult) }
  case_results
end

#update(title = @title, type_id = @type_id, priority_id = @priority_id, custom_steps = @custom_steps) ⇒ Object



35
36
37
38
39
40
# File 'lib/onlyoffice_testrail_wrapper/testrail_case.rb', line 35

def update(title = @title, type_id = @type_id, priority_id = @priority_id, custom_steps = @custom_steps)
  @section.cases_names.delete @title
  @section.cases_names[StringHelper.warnstrip!(title.to_s)] = @id
  HashHelper.parse_to_class_variable(Testrail2.http_post("index.php?/api/v2/update_case/#{@id}", title: title, type_id: type_id,
                                                                                                 priority_id: priority_id, custom_steps: custom_steps), TestrailCase)
end