Class: Datadog::CI::TestSession

Inherits:
ConcurrentSpan show all
Defined in:
lib/datadog/ci/test_session.rb

Overview

Represents the whole test session process. Documentation on test sessions is here: https://docs.datadoghq.com/continuous_integration/explorer/?tab=testruns#sessions This object can be shared between multiple threads.

Instance Attribute Summary collapse

Attributes inherited from Span

#tracer_span

Instance Method Summary collapse

Methods inherited from ConcurrentSpan

#get_tag, #initialize, #set_metric, #set_tag, #set_tags, #synchronize

Methods inherited from Span

#clear_tag, #failed!, #failed?, #get_metric, #get_tag, #git_branch, #git_commit_sha, #git_repository_url, #id, #initialize, #os_architecture, #os_platform, #os_version, #passed!, #passed?, #runtime_name, #runtime_version, #service, #set_default_tags, #set_environment_runtime_tags, #set_metric, #set_tag, #set_tags, #skipped!, #skipped?, #source_file, #to_s, #trace_id, #type, #undefined?

Constructor Details

This class inherits a constructor from Datadog::CI::ConcurrentSpan

Instance Attribute Details

#total_tests_countObject

Returns the value of attribute total_tests_count.



15
16
17
# File 'lib/datadog/ci/test_session.rb', line 15

def total_tests_count
  @total_tests_count
end

Instance Method Details

#ci_job_nameString

Return the test session's CI job name (e.g. "build", "test", etc.)

Returns:

  • (String)

    the job name for this test session.



45
46
47
# File 'lib/datadog/ci/test_session.rb', line 45

def ci_job_name
  get_tag(Ext::Environment::TAG_JOB_NAME)
end

#ci_providerString

Return the test session's CI provider name (e.g. "travis", "circleci", etc.)

Returns:

  • (String)

    the provider name for this test session.



39
40
41
# File 'lib/datadog/ci/test_session.rb', line 39

def ci_provider
  get_tag(Ext::Environment::TAG_PROVIDER_NAME)
end

#code_coverage?Boolean

Returns:

  • (Boolean)


53
54
55
# File 'lib/datadog/ci/test_session.rb', line 53

def code_coverage?
  get_tag(Ext::Test::TAG_CODE_COVERAGE_ENABLED) == "true"
end

#finishvoid

This method returns an undefined value.

Finishes the current test session.



19
20
21
22
23
# File 'lib/datadog/ci/test_session.rb', line 19

def finish
  test_visibility.deactivate_test_session

  super
end

#inheritable_tagsHash

Return the test session tags that could be inherited by sub-spans

Returns:

  • (Hash)

    the tags to be inherited by sub-spans.



59
60
61
62
63
64
65
66
67
68
69
# File 'lib/datadog/ci/test_session.rb', line 59

def inheritable_tags
  return @inheritable_tags if defined?(@inheritable_tags)

  # this method is not synchronized because it does not iterate over the tags collection, but rather
  # uses synchronized method #get_tag to get each tag value
  res = {}
  Ext::Test::INHERITABLE_TAGS.each do |tag|
    res[tag] = get_tag(tag)
  end
  @inheritable_tags = res.freeze
end

#nameString

Return the test session's name which is equal to test command used

Returns:

  • (String)

    the command for this test session.



27
28
29
# File 'lib/datadog/ci/test_session.rb', line 27

def name
  test_visibility.logical_test_session_name || "test_session"
end

#skipping_tests?Boolean

Returns:

  • (Boolean)


49
50
51
# File 'lib/datadog/ci/test_session.rb', line 49

def skipping_tests?
  get_tag(Ext::Test::TAG_ITR_TEST_SKIPPING_ENABLED) == "true"
end

#test_commandString

Return the test session's command used to run the tests

Returns:

  • (String)

    the command for this test session.



33
34
35
# File 'lib/datadog/ci/test_session.rb', line 33

def test_command
  get_tag(Ext::Test::TAG_COMMAND)
end