Module: Datadog::CI::Contrib::Minitest::Hooks

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

Overview

Lifecycle hooks to instrument Minitest::Test

Instance Method Summary collapse

Instance Method Details

#after_teardownObject



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/datadog/ci/contrib/minitest/hooks.rb', line 33

def after_teardown
  test_span = CI.active_test
  return super unless test_span

  case result_code
  when "."
    test_span.passed!
  when "E", "F"
    test_span.failed!(exception: failure)
  when "S"
    test_span.skipped!(reason: failure.message)
  end

  test_span.finish

  super
end

#before_setupObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/datadog/ci/contrib/minitest/hooks.rb', line 12

def before_setup
  super
  return unless configuration[:enabled]

  test_name = "#{class_name}##{name}"

  path, = method(name).source_location
  test_suite = Pathname.new(path.to_s).relative_path_from(Pathname.pwd).to_s

  CI.start_test(
    test_name,
    test_suite,
    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_TYPE => Ext::TEST_TYPE
    },
    service: configuration[:service_name]
  )
end