Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Cucumber contrib] remove tracking failed tests count per test suite, mark test suite as failed if any test fails #94

Merged
merged 1 commit into from
Jan 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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