Class: Itriagetestrail::TRCucumber30

Inherits:
TestRailInterface show all
Defined in:
lib/itriagetestrail/framework_bindings/trcucumber30.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



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/itriagetestrail/framework_bindings/trcucumber30.rb', line 19

def record_result(scenario)
  return if execute == false
  begin
    scenario_title_and_external_id(scenario)
    @scenario_steps = scenario.test_steps.collect(&:text).join("\n")

    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
# File 'lib/itriagetestrail/framework_bindings/trcucumber30.rb', line 6

def scenario_title_and_external_id(scenario)
  if scenario.class.to_s == 'Cucumber::RunningTestCase::ScenarioOutlineExample'
    # Remove spaces within cells to match our Cucumber 1.3 implementation
    scenario.cell_values.each { |cell| cell.gsub!(/\s+/, '') }
    @scenario_title = "#{scenario.name.match(/\b.*Example/)}: #{scenario.cell_values}"
    @external_id = "#{scenario.feature.short_name}\;#{@scenario_title}"[0, 249]
  else
    @external_id = "#{scenario.feature.short_name}\;#{scenario.name}"
    @scenario_title = scenario.name
  end
  @scenario_tags = scenario.source_tag_names
end

#shutdownObject



37
38
39
40
41
42
# File 'lib/itriagetestrail/framework_bindings/trcucumber30.rb', line 37

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