Module: Datadog::CI::Contrib::RSpec::ExampleGroup::ClassMethods

Defined in:
lib/datadog/ci/contrib/rspec/example_group.rb

Overview

Instance methods for configuration

Instance Method Summary collapse

Instance Method Details

#run(reporter = ::RSpec::Core::NullReporter) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/datadog/ci/contrib/rspec/example_group.rb', line 18

def run(reporter = ::RSpec::Core::NullReporter)
  return super if ::RSpec.configuration.dry_run? && !datadog_configuration[:dry_run_enabled]
  return super unless datadog_configuration[:enabled]
  return super unless top_level?

  suite_name = "#{description} at #{file_path}"
  test_suite = test_visibility_component.start_test_suite(
    suite_name,
    tags: {
      CI::Ext::Test::TAG_SOURCE_FILE => Git::LocalRepository.relative_to_root([:file_path]),
      CI::Ext::Test::TAG_SOURCE_START => [:line_number].to_s
    }
  )

  success = super
  return success unless test_suite

  if success && test_suite.any_passed?
    test_suite.passed!
  elsif success
    test_suite.skipped!
  else
    test_suite.failed!
  end

  test_suite.finish

  success
end