Skip to content

Commit

Permalink
[Cucumber contrib] remove tracking failed test scount per test suite,…
Browse files Browse the repository at this point in the history
… mark test suite as failed if any test fails
  • Loading branch information
anmarchenko committed Jan 3, 2024
1 parent 3688bc2 commit adf5503
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
19 changes: 8 additions & 11 deletions lib/datadog/ci/contrib/cucumber/formatter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ def initialize(config)
@failed_tests_count = 0

@current_test_suite = nil
@failed_tests_in_current_test_suite = 0

bind_events(config)
end
Expand Down Expand Up @@ -75,11 +74,11 @@ def on_test_case_finished(event)
# We need to track overall test failures manually if we are using cucumber < 8.0 because
# TestRunFinished event does not have a success attribute before 8.0.
#
# To track whether test suite failed or passed we need to
# track the number of failed tests in the current test suite.
if event.result.failed?
@failed_tests_count += 1
@failed_tests_in_current_test_suite += 1

test_suite = @current_test_suite
test_suite.failed! if test_suite
end

finish_test(test_span, event.result)
Expand Down Expand Up @@ -132,19 +131,17 @@ def finish_session(result)
def start_test_suite(test_suite_name)
finish_current_test_suite

@current_test_suite = CI.start_test_suite(test_suite_name)
test_suite = CI.start_test_suite(test_suite_name)
# will be overridden if any test fails
test_suite.passed!

@current_test_suite = test_suite
end

def finish_current_test_suite
test_suite = @current_test_suite
return unless test_suite

if @failed_tests_in_current_test_suite.zero?
test_suite.passed!
else
test_suite.failed!
end
@failed_tests_in_current_test_suite = 0
test_suite.finish
end

Expand Down
1 change: 0 additions & 1 deletion sig/datadog/ci/contrib/cucumber/formatter.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ module Datadog
private
@failed_tests_count: Integer
@current_test_suite: Datadog::CI::Span?
@failed_tests_in_current_test_suite: Integer

attr_reader config: untyped

Expand Down

0 comments on commit adf5503

Please sign in to comment.