Skip to content

Commit

Permalink
Merge pull request #18 from reportportal/feature/cucumber3
Browse files Browse the repository at this point in the history
Cucumber 3
  • Loading branch information
avarabyeu authored Jan 4, 2018
2 parents 447d93b + b7f0c77 commit 12ed593
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

source 'https://rubygems.org'

gem 'cucumber', '~> 2.2'
gem 'cucumber', '~> 3'
gem 'rest-client'
gem 'rubytree', git: 'https://github.com/razboev/RubyTree'
gem 'rspec'
Expand Down
6 changes: 3 additions & 3 deletions lib/report_portal/cucumber/formatter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,12 @@ def initialize(config)

@io = config.out_stream

[:before_test_case, :after_test_case, :before_test_step, :after_test_step].each do |event_name|
[:test_case_started, :test_case_finished, :test_step_started, :test_step_finished].each do |event_name|
config.on_event event_name do |event|
@queue.push([event_name, event, ReportPortal.now])
end
end
config.on_event :test_run_finished, &method(:on_test_run_finished)
end

def puts(message)
Expand All @@ -56,8 +57,7 @@ def embed(*args)
@queue.push([:embed, *args, ReportPortal.now])
end

# @api private
def done
def on_test_run_finished(_event)
@queue.push([:done, ReportPortal.now])
sleep 0.03 while !@queue.empty? || @queue.num_waiting == 0 # TODO: how to interrupt launch if the user aborted execution
@thread.kill
Expand Down
16 changes: 8 additions & 8 deletions lib/report_portal/cucumber/report.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def start_launch(desired_time = ReportPortal.now)
end
end

def before_test_case(event, desired_time = ReportPortal.now) # TODO: time should be a required argument
def test_case_started(event, desired_time = ReportPortal.now) # TODO: time should be a required argument
test_case = event.test_case
feature = test_case.feature
unless same_feature_as_previous_test_case?(feature)
Expand All @@ -78,7 +78,7 @@ def before_test_case(event, desired_time = ReportPortal.now) # TODO: time should
ReportPortal.current_scenario.id = ReportPortal.start_item(scenario_node)
end

def after_test_case(event, desired_time = ReportPortal.now)
def test_case_finished(event, desired_time = ReportPortal.now)
result = event.result
status = result.to_sym
issue = nil
Expand All @@ -90,11 +90,11 @@ def after_test_case(event, desired_time = ReportPortal.now)
ReportPortal.current_scenario = nil
end

def before_test_step(event, desired_time = ReportPortal.now)
def test_step_started(event, desired_time = ReportPortal.now)
test_step = event.test_step
if step?(test_step) # `after_test_step` is also invoked for hooks
step_source = test_step.source.last
message = "-- #{step_source.keyword}#{step_source.name} --"
message = "-- #{step_source.keyword}#{step_source.text} --"
if step_source.multiline_arg.doc_string?
message << %(\n"""\n#{step_source.multiline_arg.content}\n""")
elsif step_source.multiline_arg.data_table?
Expand All @@ -104,7 +104,7 @@ def before_test_step(event, desired_time = ReportPortal.now)
end
end

def after_test_step(event, desired_time = ReportPortal.now)
def test_step_finished(event, desired_time = ReportPortal.now)
test_step = event.test_step
result = event.result
status = result.to_sym
Expand All @@ -114,7 +114,7 @@ def after_test_step(event, desired_time = ReportPortal.now)
ex = result.exception
sprintf("%s: %s\n %s", ex.class.name, ex.message, ex.backtrace.join("\n "))
else
sprintf("Undefined step: %s:\n%s", test_step.name, test_step.source.last.backtrace_line)
sprintf("Undefined step: %s:\n%s", test_step.text, test_step.source.last.backtrace_line)
end
ReportPortal.send_log(:error, exception_info, time_to_send(desired_time))
end
Expand Down Expand Up @@ -167,13 +167,13 @@ def time_to_send(desired_time)
end

def same_feature_as_previous_test_case?(feature)
@feature_node && @feature_node.name == feature.file.split(File::SEPARATOR).last
@feature_node && @feature_node.name == feature.location.file.split(File::SEPARATOR).last
end

def start_feature_with_parentage(feature, desired_time)
parent_node = @root_node
child_node = nil
path_components = feature.file.split(File::SEPARATOR)
path_components = feature.location.file.split(File::SEPARATOR)
path_components.each_with_index do |path_component, index|
child_node = parent_node[path_component]
unless child_node
Expand Down
2 changes: 1 addition & 1 deletion lib/report_portal/tasks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
require 'rake'
require 'pathname'
require 'tempfile'
require 'reportportal'
require_relative '../reportportal'

namespace :reportportal do
desc 'Start launch in Report Portal and print its id to $stdout (needed for use with ReportPortal::Cucumber::AttachToLaunchFormatter)'
Expand Down

0 comments on commit 12ed593

Please sign in to comment.