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

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

Instance Method Summary collapse

Instance Method Details

#after_setupObject



64
65
66
67
68
# File 'lib/datadog/ci/contrib/minitest/test.rb', line 64

def after_setup
  super
ensure
  finish_datadog_before_step
end

#after_teardownObject



87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/datadog/ci/contrib/minitest/test.rb', line 87

def after_teardown
  test_span = _dd_test_tracing_component.active_test
  return super unless test_span

  begin
    super
  ensure
    finish_datadog_after_step
    finish_with_result(test_span, result_code)

    # remove failures if failure can be ignored because of retries
    self.failures = [] if test_span.should_ignore_failures?
  end
end

#before_setupObject



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

def before_setup
  test_span = _dd_test_tracing_component.active_test
  return super unless test_span

  @datadog_before_step_failures_count = failures.length
  @datadog_before_step_span = _dd_test_tracing_component.trace(
    Ext::BEFORE_STEP_SPAN_NAME,
    type: Ext::STEP_SPAN_TYPE
  )

  super
end

#before_teardownObject



70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/datadog/ci/contrib/minitest/test.rb', line 70

def before_teardown
  test_span = _dd_test_tracing_component.active_test
  return super unless test_span

  # Setup failures prevent Minitest from invoking after_setup, so
  # close a still-active before span before teardown begins.
  finish_datadog_before_step

  @datadog_after_step_failures_count = failures.length
  @datadog_after_step_span = _dd_test_tracing_component.trace(
    Ext::AFTER_STEP_SPAN_NAME,
    type: Ext::STEP_SPAN_TYPE
  )

  super
end

#runObject



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

def run
  return super unless datadog_configuration[:enabled]

  return run_without_datadog_reentry if datadog_run_reentered?

  test_suite = start_datadog_test_suite_if_parallel
  if test_suite&.should_skip?
    return skip_datadog_suite(test_suite)
  end

  test_span = start_datadog_test
  return skip_datadog_test(test_span) if test_span&.should_skip?

  super
end