Class: Itriagetestrail::TRCucumber13

Inherits:
TestRailInterface show all
Defined in:
lib/itriagetestrail/framework_bindings/trcucumber13.rb

Instance Attribute Summary

Attributes inherited from TestRailInterface

#batch_size, #client, #execute, #external_results, #pool, #results, #run_id, #sections, #test_case_ids, #test_cases

Instance Method Summary collapse

Methods inherited from TestRailInterface

#_execute, #_time_zone, #clear_results, #close_run, #close_run?, #config, #create_run_id, #delete_temp_files, #initialize, #initialize_temp_files, #initialize_variables, #make_connection, #plan_tempfile_name, #run_tempfile_name, #setup, #setup?, #tag_ids, #testrail_online

Methods included from TestResults

#read_batch_file, #send_batch_results_to_testrail, #send_results_to_testrail, #store_result, #store_results_to_batch_file, #update_test_suite

Methods included from TestRuns

#add_testrail_run, #existing_cases_from_description, #existing_cases_from_run, #extend_testrail_run

Methods included from TestPlans

#add_plan_entry, #add_testrail_plan, #append_configuration_ids, #config_id, #configuration_group, #configuration_ids, #configurations

Methods included from TestCases

#add_testrail_test_case, #app_version_label, #associate_result, #jenkins_build_label, #test_name, #testrail_ids, #testrail_test_case_id, #time_zone_label

Methods included from Sections

#add_testrail_section, #testrail_section_id, #testrail_sections

Methods included from Milestones

#fetch_milestone, #milestone_archive_name, #milestone_due_date, #milestone_period_start, #milestone_runs, #normalize_milestone, #normalize_origin, #rename_milestone, #reset_milestone

Methods included from Suites

#add_testrail_suite, #testrail_suite_id, #testrail_suites

Methods included from Projects

#project_by_id, #project_by_name, #projects, #set_project

Constructor Details

This class inherits a constructor from Itriagetestrail::TestRailInterface

Instance Method Details

#record_result(scenario) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/itriagetestrail/framework_bindings/trcucumber13.rb', line 22

def record_result(scenario)
  return if execute == false
  begin
    scenario_title_and_external_id(scenario)

    if scenario.passed?
      store_result(@scenario_title, @external_id, @scenario_steps, 1, '')
    else
      store_result(@scenario_title, @external_id, @scenario_steps,
                   (ENV['RERUN'] ? 5 : 4).to_s.to_i, "#{scenario.exception.class}\n" \
                   "#{scenario.exception}\n#{scenario.exception.backtrace}")
    end
  rescue StandardError => exception
    puts "TESTRAIL ENCOUNTERED AN ERROR: #{exception}\n #{@external_id} \n\n"
  end
end

#scenario_title_and_external_id(scenario) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/itriagetestrail/framework_bindings/trcucumber13.rb', line 6

def scenario_title_and_external_id(scenario)
  if scenario.class.to_s == 'Cucumber::Ast::OutlineTable::ExampleRow'
    scenario_cell_id = []
    scenario.name.split('|')[1..50].each { |cell| scenario_cell_id << cell.gsub(/[\| "]/, '') }
    @scenario_title = "#{scenario.scenario_outline.title}, Example: #{scenario_cell_id}"
    @external_id = "#{scenario.scenario_outline.feature.name};#{@scenario_title}"[0, 249]
    @scenario_steps = scenario.scenario_outline.raw_steps.select { 'name' }.collect(&:name).join("\n")
  else
    #    identifiers: scenario.feature.name, scenario.name
    @external_id = "#{scenario.feature.title};#{scenario.title}"
    @scenario_title = scenario.title
    @scenario_steps = scenario.steps.select { 'name' }.collect(&:name).join("\n")
  end
  @scenario_tags = scenario.source_tag_names
end

#shutdownObject



39
40
41
42
43
44
# File 'lib/itriagetestrail/framework_bindings/trcucumber13.rb', line 39

def shutdown
  return unless execute
  sleep 3 # testrail service rate limit precaution
  send_results_to_testrail
  super
end