Module: Datadog::CI::Contrib::Minitest::Test::InstanceMethods

Defined in:
lib/datadog/ci/contrib/minitest/test.rb

Instance Method Summary collapse

Instance Method Details

#after_teardownObject



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/datadog/ci/contrib/minitest/test.rb', line 49

def after_teardown
  test_span = test_visibility_component.active_test
  return super unless test_span

  finish_with_result(test_span, result_code)

  # remove failures if test passed at least once on retries
  self.failures = [] if test_span.any_retry_passed?

  if Helpers.parallel?(self.class)
    finish_with_result(test_span.test_suite, result_code)
  end

  super
end

#before_setupObject



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
47
# File 'lib/datadog/ci/contrib/minitest/test.rb', line 20

def before_setup
  super
  return unless datadog_configuration[:enabled]

  test_suite_name = Helpers.test_suite_name(self.class, name)
  if Helpers.parallel?(self.class)
    test_suite_name = "#{test_suite_name} (#{name} concurrently)"

    # for parallel execution we need to start a new test suite for each test
    test_visibility_component.start_test_suite(test_suite_name)
  end

  source_file, line_number = method(name).source_location

  test_span = test_visibility_component.trace_test(
    name,
    test_suite_name,
    tags: {
      CI::Ext::Test::TAG_FRAMEWORK => Ext::FRAMEWORK,
      CI::Ext::Test::TAG_FRAMEWORK_VERSION => CI::Contrib::Minitest::Integration.version.to_s,
      CI::Ext::Test::TAG_SOURCE_FILE => Git::LocalRepository.relative_to_root(source_file),
      CI::Ext::Test::TAG_SOURCE_START => line_number.to_s
    },
    service: datadog_configuration[:service_name]
  )
  test_span&.itr_unskippable! if self.class.dd_suite_unskippable? || self.class.dd_test_unskippable?(name)
  skip(CI::Ext::Test::ITR_TEST_SKIP_REASON) if test_span&.skipped_by_itr?
end