Module: Datadog::CI::Contrib::Minitest::Runner::ClassMethods

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

Instance Method Summary collapse

Instance Method Details

#init_plugins(*args) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/datadog/ci/contrib/minitest/runner.rb', line 17

def init_plugins(*args)
  super

  return unless datadog_configuration[:enabled]

  tests_count = ::Minitest::Runnable.runnables.sum { |runnable| runnable.runnable_methods.size }

  test_visibility_component.start_test_session(
    tags: {
      CI::Ext::Test::TAG_FRAMEWORK => Ext::FRAMEWORK,
      CI::Ext::Test::TAG_FRAMEWORK_VERSION => datadog_integration.version.to_s
    },
    service: datadog_configuration[:service_name],
    estimated_total_tests_count: tests_count,
    # if minitest is being used with a parallel runner, then tests split will happen by example, not by test suite
    # we need to always start/stop test suites in the parent process in this case
    local_test_suites_mode: false
  )
  test_visibility_component.start_test_module(Ext::FRAMEWORK)
end

#run_one_method(klass, method_name) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/datadog/ci/contrib/minitest/runner.rb', line 38

def run_one_method(klass, method_name)
  return super unless datadog_configuration[:enabled]

  result = nil

  test_retries_component.with_retries do
    result = super
  end

  # get the current test suite and mark this method as done, so we can check if all tests were executed
  # for this test suite
  test_suite_name = Helpers.test_suite_name(klass, method_name)
  test_suite = test_visibility_component.active_test_suite(test_suite_name)
  test_suite&.expected_test_done!(method_name)

  result
end