Class: ParallelReportPortal::Cucumber::Report
- Inherits:
-
Object
- Object
- ParallelReportPortal::Cucumber::Report
- Defined in:
- lib/parallel_report_portal/cucumber/report.rb
Overview
Report object. This handles the management of the state hierarchy and the issuing of the requests to the HTTP module.
Defined Under Namespace
Classes: Feature
Constant Summary collapse
- LOG_LEVELS =
{ error: 'ERROR', warn: 'WARN', info: 'INFO', debug: 'DEBUG', trace: 'TRACE', fatal: 'FATAL', unknown: 'UNKNOWN' }
Instance Attribute Summary collapse
-
#launch_id ⇒ Object
readonly
Returns the value of attribute launch_id.
Instance Method Summary collapse
- #check_faraday_compatibility ⇒ Object
- #feature_finished(clock) ⇒ Object
-
#feature_started(feature, clock) ⇒ Object
Called to indicate that a feature has started.
-
#initialize(ast_lookup = nil) ⇒ Report
constructor
Create a new instance of the report.
-
#launch_finished(clock) ⇒ Object
Called to finish a launch.
-
#launch_started(start_time) ⇒ String
Issued to start a launch.
- #test_case_finished(event, clock) ⇒ Object
- #test_case_started(event, clock) ⇒ Object
- #test_step_finished(event, clock) ⇒ Object
- #test_step_started(event, clock) ⇒ Object
Constructor Details
#initialize(ast_lookup = nil) ⇒ Report
Create a new instance of the report
28 29 30 31 32 33 |
# File 'lib/parallel_report_portal/cucumber/report.rb', line 28 def initialize(ast_lookup = nil) @feature = nil @tree = Tree::TreeNode.new( 'root' ) @ast_lookup = ast_lookup check_faraday_compatibility end |
Instance Attribute Details
#launch_id ⇒ Object (readonly)
Returns the value of attribute launch_id.
12 13 14 |
# File 'lib/parallel_report_portal/cucumber/report.rb', line 12 def launch_id @launch_id end |
Instance Method Details
#check_faraday_compatibility ⇒ Object
35 36 37 38 39 |
# File 'lib/parallel_report_portal/cucumber/report.rb', line 35 def check_faraday_compatibility if Gem::Version.create(Faraday::VERSION) < Gem::Version.create('2.0') Kernel.warn("Minimum of Faraday v2 is expected for compatibility with parallel_report_portal", category: :deprecated) end end |
#feature_finished(clock) ⇒ Object
85 86 87 88 89 |
# File 'lib/parallel_report_portal/cucumber/report.rb', line 85 def feature_finished(clock) if @feature resp = ParallelReportPortal.req_feature_finished(@feature.id, clock) end end |
#feature_started(feature, clock) ⇒ Object
Called to indicate that a feature has started.
79 80 81 82 83 |
# File 'lib/parallel_report_portal/cucumber/report.rb', line 79 def feature_started(feature, clock) parent_id = hierarchy(feature, clock) feature = feature.feature if ParallelReportPortal.req_feature_started(launch_id, parent_id, feature, clock) end |
#launch_finished(clock) ⇒ Object
Called to finish a launch. Any open children items will be closed in the process.
66 67 68 69 70 71 72 73 74 |
# File 'lib/parallel_report_portal/cucumber/report.rb', line 66 def launch_finished(clock) @tree.postordered_each do |node| response = ParallelReportPortal.req_feature_finished(node.content, clock) unless node.is_root? parse_report_link_from_response(response) end response = ParallelReportPortal.req_launch_finished(launch_id, clock) parse_report_link_from_response(response) ParallelReportPortal.launch_finished_block.call if ParallelReportPortal.launch_finished_block end |
#launch_started(start_time) ⇒ String
Issued to start a launch. It is possilbe that this method could be called from multiple processes for the same launch if this is being run with parallel tests enabled. A temporary launch file will be created (using exclusive locking). The first time this method is called it will write the launch id to the launch file, subsequent calls by other processes will read this launch id and use that.
50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/parallel_report_portal/cucumber/report.rb', line 50 def launch_started(start_time) ParallelReportPortal.file_open_exlock_and_block(ParallelReportPortal.launch_id_file, 'a+' ) do |file| if file.size == 0 @launch_id = ParallelReportPortal.req_launch_started(start_time) file.write(@launch_id) file.flush else @launch_id = file.readline end @launch_id end end |
#test_case_finished(event, clock) ⇒ Object
98 99 100 101 102 103 104 105 106 107 |
# File 'lib/parallel_report_portal/cucumber/report.rb', line 98 def test_case_finished(event, clock) result = event.result status = result.to_sym = nil if [:undefined, :pending].include?(status) status = :failed = result. end resp = ParallelReportPortal.req_test_case_finished(@test_case_id, status, clock) end |
#test_case_started(event, clock) ⇒ Object
91 92 93 94 95 96 |
# File 'lib/parallel_report_portal/cucumber/report.rb', line 91 def test_case_started(event, clock) test_case = lookup_test_case(event.test_case) feature = lookup_feature(event.test_case) feature = current_feature(feature, clock) @test_case_id = ParallelReportPortal.req_test_case_started(launch_id, feature.id, test_case, clock) end |
#test_step_finished(event, clock) ⇒ Object
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
# File 'lib/parallel_report_portal/cucumber/report.rb', line 124 def test_step_finished(event, clock) test_step = event.test_step result = event.result status = result.to_sym detail = nil if [:failed, :pending, :undefined].include?(status) if [:failed, :pending].include?(status) ex = result.exception detail = sprintf("%s: %s\n %s", ex.class.name, ex., ex.backtrace.join("\n ")) elsif !hook?(test_step) step_source = lookup_step_source(test_step) detail = sprintf("Undefined step: %s:\n%s", step_source.text, step_source.source.last.backtrace_line) end elsif !hook?(test_step) step_source = lookup_step_source(test_step) detail = "#{step_source.text}" end ParallelReportPortal.req_log(@test_case_id, detail, status_to_level(status), clock) if detail end |
#test_step_started(event, clock) ⇒ Object
109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/parallel_report_portal/cucumber/report.rb', line 109 def test_step_started(event, clock) test_step = event.test_step if !hook?(test_step) step_source = lookup_step_source(test_step) detail = "#{step_source.keyword} #{step_source.text}" if ( ? test_step : step_source).multiline_arg.doc_string? detail << %(\n"""\n#{( ? test_step : step_source).multiline_arg.content}\n""") elsif ( ? test_step : step_source).multiline_arg.data_table? detail << ( ? test_step : step_source).multiline_arg.raw.reduce("\n") {|acc, row| acc << "| #{row.join(' | ')} |\n"} end ParallelReportPortal.req_log(@test_case_id, detail, status_to_level(:trace), clock) end end |